Connecting VBS C++ code with SQL Server - c++

ok so i have searched the internet for a solution but i seem to not be getting it.
im running Windows 7, 32-bit OS
i installed Microsoft SQL Server Management Studio Express 2012 with all the tools.
I created a simple database with a table and some entries.
I currently use Microsoft Visual C++ 2010 Express to design applications. I want to write a really simple application that connects to this database just to see how it works.
By the way this is all done on a one machine(localhost)
here is the c++ code:
//not sure if some of these are even needed
#include <iostream>
#include <conio.h>
#include <string>
#include <fstream>
#include <windows.h>
#include <C:\\Program Files\\Microsoft SQL Server\\110\\SDK\\Include\\sqlncli.h>
using namespace std;
int main()
{
//what would i put here?
}
What would be the simplest syntax be for the main function to connect to the SQL server?
I have linked the library file and header file in the project properties like so:
Header file Name: sqlncli.h
Project Properties - configuration properties - C/C++ - Additional Include Directories - *C:\Program Files\Microsoft SQL Server\110\SDK\Include*
Library File Name: sqlncli11.lib
this time under Linker in properties - Additional Include Directories - *C:\Program Files\Microsoft SQL Server\110\SDK\Lib\x86*
Some people mentioned a DLL but i could not find one.
So...
*I installed correct SQL package
*Created a database with a table and values
*included library and header file in C++ code
*configured properties to look for them.
Is this supposed to be this confusing or am i really missing something here?

Related

sdk-11.1.0.7.0-linux-x86_64/instantclient_11_1/sdk/include/nzerror.h:115:11: fatal error: oratypes.h: No such file or directory

I am trying to connect oracle 11g express on my Windows 10 installed by C++ program writing in Linux Ubuntu 18.4 LTS. I set path of include to includes file given by Oracle. I set path of Directories to given shared libraries by oracle. I just set namespace oracle::occi. The main method still empty I just build project but getting error
./../../Desktop/oracle OCI/sdk-11.1.0.7.0-linux-x86_64/instantclient_11_1/sdk/include/nzerror.h:115:11: fatal error: oratypes.h: No such file or directory.
I am using Netbeans on Ubuntu for coding of C++; I want to connect Oracle database on Windows 10 over the network by just change localhost to IP.
One more thing, I created a project in Visual Studio 2019 import all library for Windows it work but fetch one record and exception caught at some thing like Myproxy Error function.
Visual Studio problem later but I want it on Linux first.
#include <cstdlib.h>
using namespace std;
using namespace oracle::occi;
void main(){
}
I just do this and set the paths which I explained.

Can't include mysql

I have been trying for a while now. I have been asked to do a few modifications on a big program, and it requires a lot of libs. All of them were succesfully added, except mysql.
I downloaded the libs several times and tried a lot of times.
I am on Windows using Netbeans and C++.
The test I decided to do is simple: create an empty program and try to include mysql. I didn't have any success:
#include <cstdlib>
#include <mysql/mysql.h>
using namespace std;
int main(int argc, char** argv) {
return 0;
}
This program won't work even if I replace #include <mysql/mysql.h> with #include <mysql.h>.
The error NetBeans gives me is the following:
main.cpp:15:25: fatal error: mysql/mysql.h: No such file or directory
These images show how I altered the project options on Linker and C/C++ options:
Parameters
The folder showing on the C image does contain a mysql.h, i triple checked twice.
I also have added the paths with includes to CodeAssistance.
Many similar questions were left unanswered for years now on several forums, even on stackoverflow, and I can't seem to work this out. This thread may have a final answer to those of us who stumble upon this.
It is not able to find the file
At this point, your program would be pointing to something like this:
cl /I "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include"
mysql1.c
So you needed to include the directory that contains mysql.h as well. So the above would changed to:
cl /I "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include"
/I "C:\Program Files\MySQL\MySQL Server 5.5\include" mysql1.c
verify the header file exist in the path /usr/include/mysql/mysql.h or installed some where else. If you have installed the header files somewhere else ( add that location with -I/.

Visual C++ can't open include file 'iostream'

I am new to C++. I just started! I tried a code on Visual C++ 2010 Express version, but I got the following code error message.
------ Build started: Project: abc, Configuration: Debug Win32 ------
ugo.cpp
c:\users\castle\documents\visual studio 2010\projects\abc\abc\ugo.cpp(3): fatal error C1083: Cannot open include file: 'iostream': No such file or directory
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
This is the code:
// first.cpp -- displays a message
#include <iostream> // A PREPROCESSOR directive
int main(void) // Function header
{ // Start of a function body
using namespace std;
cout << "Come up and C++ me sometime.\n"; // Message
// Start a new line
cout << "Here is the total: 1000.00\n";
cout << "Here we go!\n";
return 0;
}
Replace
#include <iostream.h>
with
using namespace std;
#include <iostream>
Some things that you should check:
Check the include folder in your version of Visual Studio (in "C:\Program Files\Microsoft Visual Studio xx.x\VC\include", check for the file which you are including, iostream, make sure it's there).
Check your projects Include Directories in <Project Name> → Properties → Configuration Properties → VC++ Directories → Include Directories (it should look like this: $(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include;$(FrameworkSDKDir)\include;)
Make sure that you selected the correct project for this code
(menu File → New → Project → Visual C++ → Win32 Console Application)
Make sure that you don't have <iostream.h> anywhere in your code files, Visual Studio doesn't support that (in the same project, check your other code files, .cpp and .h files for <iostream.h> and remove it).
Make sure that you don't have more than one main() function in your project code files (*in the same project, check your other code files, .cpp and .h files for the* main()` function and remove it or replace it with another name).
Some things you could try building with:
Exclude using namespace std; from your main() function and put it after the include directive.
Use std::cout without using namespace std;.
I had this exact same problem in Visual Studio 2015. It looks like as of Visual Studio 2010 and later you need to include #include "stdafx.h" in all your projects.
#include "stdafx.h"
#include <iostream>
using namespace std;
The above worked for me. The below did not:
#include <iostream>
using namespace std;
This also failed:
#include <iostream>
using namespace std;
#include "stdafx.h"
You are more than likely missing $(IncludePath) within Properties → VC++ Directories → Include Directories.
Adding this should make iostream and others visible again. You probably deleted it by mistake while setting up your program.
If your include directories are referenced correctly in the VC++ project property sheet → Configuration Properties → VC++ directories → Include directories, the path is referenced in the macro $(VC_IncludePath).
In my Visual Studio 2015 this evaluates to:
"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include"
using namespace std;
#include <iostream>
That did it for me.
It is possible that your compiler and the resources installed around it were somehow incomplete. I recommend re-installing your compiler: it should work after that.
I got this error when I created an 'Empty' console application in Visual Studio 2015. I recreated the application, leaving the 'Empty' box unchecked. It added all of the necessary libraries.
Make sure you have Desktop Development with C++ installed.
I was experiencing the same problem, because I only had Universal Windows Platform Development installed.
Microsoft Visual Studio is funny. When you're using the installer, you must checkbox a lot of options to bypass the .NET framework (somewhat) to make more C++ instead of C# applications, such as the CLR options under desktop development... in the Visual Studio installer.... the difference is the C++ Win32 console project or a C++ CLR console project.
So what’s the difference? Well, I'm not going to list all of the files CLR includes, but since most good C++ kernels are in Linux... So CLR allows you to bypass a lot of the Windows .NET framework because Visual Studio was really meant for you to make applications in C#.
Here’s a C++ Win32 console project!
#include "stdafx.h"
#include <iostream>
using namespace std;
int main()
{
cout << "Hello, World!" << endl;
return 0;
}
Now here’s a C++ CLR console project!
#include "stdafx.h"
using namespace System;
int main(array<System::String ^> ^args)
{
Console::WriteLine("Hello, World!");
return 0;
}
Both programs do the same thing .... the CLR just looks more frameworked class overloading methodology, so Microsoft can great its own vast library you should familiarize yourself with if so inclined.
Keywords (C++)
Other things you'll learn from debugging to add for error avoidance:
#ifdef _MRC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif
If you created an environment variable with the name IncludePath, try renaming it to something else.
This name will override $(IncludePath) inside project properties.
Quick fix for small programs:
Add: #include <cstdlib>
In my case, my Visual Studio 2015 installed without selecting C++ package, and Visual Studio 2017 is installed with the C++ package. If I use Visual Studio 2015, opening a C++ project will show this error, and using Visual Studio 2017 will be no error.
I had this problem too. I used this code (before main();) in Visual Studio 2022, and it turned OK:
#include "pch.h"
#include <iostream>
using namespace std;
using namespace winrt;
using namespace Windows::Foundation;
In my case, the error occurred when I created a file in VS Code, without giving the .cpp extension. It resolved when I renamed it with the .cpp.
// first.cpp -- displays a message
#include <iostream> // a PREPROCESSOR directive
using namesapce std;
int main() // function header
{ // start of a function body
///using namespace std;
cout << "Come up and C++ me sometime.\n"; // message
// start a new line
cout << "Here is the total: 1000.00\n";
cout << "Here we go!\n";
return 0;
}

How to connect to Oracle in C++?

I tried to connect to Oracle using C++ but it is giving me error stating that DBManger.h not found. I have also tried using occi.h but got the same error of not found or No Such Directory.
I have installed Oracle 11g and it contains the OCI Liabraries also.
I located the specififc folders also where the OCI libraries are present . In my system they are at location E:\app\user\product\11.1.0\db_1\OCI\lib\MSVC\vc8.
I have also set the Path starting with Oracle home. But, still my program is not able to find the header files.
Any help would be greatly appreciated? I Googled a lot but found the same solution stating that locate the folder where the OCI libraries are available. I am posting my code below written in Visual Studio 2008:
I have written a very small script and just included the header files. Not even done the connectivity:
#include <occi.h>
#include <iostream>
using namespace oracle::occi;
using namespace std;
class DataBaseConnectionTest
{
public:
void test()
{
cout<<"Hello from test"<<'\n';
}
};
void main()
{
DataBaseConnectionTest *dbc=new DataBaseConnectionTest();
dbc->test();
}
Modify your project properties, add the E:\app...vc8 directory name to the Addition include directories. It's under C++/General. No need to double every \ in that one.
You'll probably need a similar treatment for the OCI library file anyway. The include file is only half the puzzle, the other half is the LIB.
You could consider OTL as alternative to OCI. Then your code could be more portable. I used it many years ago, interfacing SqlServer, and was surprised by the clean design and the raw speed (way faster than MFC+ODBC...). Also, I had a problem and Sergei gave me immediate assistance.

Berkeley DB(Unable to Locate Component)

I have a problem with berkeley DB. I get a dialog titled "Unable To Locate Componenent" saying "This application has failed to start because libdb48.dll was not found. Re-installing the application may fix this problem", then it crashes after clicking ok. I got the error message when running these simple code below:
#include <iostream>
#include <string>
#include <db_cxx.h>
using namespace std;
int main()
{
Db db(0, 0);
}
I already set the Additional include directories to the "build_windows" directory and I have linked to the "libdb48.lib". I honestly do not know what to do here. The funny part is, I googled and I had 0 pages returned.
I am using visual studio c++ 2008 and Berkeley DB 4.8.24
Thanks
Where is libdb48.dll? Is it installed? Where? A hackish solution that should make it work is to copy libdb48.dll into c:\windows\system32. If that solves the problem, then you know that the DLL just wasn't on the path. Then you can find a more appropriate place to put it.