I currently have a c++ program that I have built that talks to a MySQL database but my requirements have changed and I need a way for my program now to be able to talk to a MSSQL database.
Is there any tutorials out there for MSSQL connectivity with C++? I will be building my C++ program with devcpp so please no tutorials that require you to use visual C++
How im connecting now is using wht comes with the mysql download from the their website. I downloaded their source code and it came with a .dll file and a header file which i just included into my script. With the dll file I just need to have that in the same directory *** the compiled exe.
Once I had included the header file into my script i just found a few websites with examples on how to connect using what I have.
Now i presume its similar with MSSQL and I have found serveral header files and dlls ect for MSSQL but I cant find any examples or tutorials for me to learn from.
I currently have a c++ program that I have built that talks to a MySQL database but my requirements have changed and I need a way for my program now to be able to talk to a MSSQL database.
Is there any tutorials out there for MSSQL connectivity with C++? I will be building my C++ program with devcpp so please no tutorials that require you to use visual C++
Cheers
what is mssql?
scot2500uk.
let me also learn c++
i m a beginner and so can u please help me in learning c++.
i know c language(basics).
thanku.
Last edited by Nico; 04-01-08 at 11:04 AM.
Reason: Merged.
scot2500uk.
let me also learn c++
i m a beginner and so can u please help me in learning c++.
i know c language(basics).
thanku.
Manstard I cant teach you C++ because Im at the same level as you. Ive been taught C at Uni and the only bit of C++ that ive learnt is what Ive learnt from C. C and C++ seem fairly similar but C++ seems to do a hell of a lot more.
With odbc you should be able to switch between MSSQL and MySql relatively simply. (Just by changing your connection string).
Ive tried this tutorial and to be honest would prefer to use odbc as all the machines in the office are set up with odbc connections. the problem with that tutorial is that I just cant get it to work. Dev-Cpp just dont like those header files cos when i try to compile I get hundreds of errors
Code:
Compiler: Default compiler
Building Makefile: "C:\Documents and Settings\CarissS\Desktop\test\Makefile.win"
Executing make...
make.exe -f "C:\Documents and Settings\CarissS\Desktop\test\Makefile.win" all
g++.exe -c main.cpp -o main.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include" -I"C:/Dev-Cpp/include" -O3 -mwindows
In file included from C:/Dev-Cpp/include/sql.h:25,
from main.cpp:3:
C:/Dev-Cpp/include/sqltypes.h:137: error: `HWND' does not name a type
C:/Dev-Cpp/include/sqltypes.h:275: error: `DWORD' does not name a type
C:/Dev-Cpp/include/sqltypes.h:276: error: `WORD' does not name a type
C:/Dev-Cpp/include/sqltypes.h:277: error: `WORD' does not name a type
C:/Dev-Cpp/include/sqltypes.h:278: error: `BYTE' does not name a type
In file included from main.cpp:5:
C:/Dev-Cpp/include/sqlext.h:1682: error: `SQLHWND' has not been declared
C:/Dev-Cpp/include/sqlext.h:1688: error: ISO C++ forbids declaration of `hwnd' with no type
C:/Dev-Cpp/include/sqlext.h:2013: warning: `__stdcall__' attribute only applies to function types
C:/Dev-Cpp/include/sqlext.h:2013: error: `LPWSTR' was not declared in this scope
C:/Dev-Cpp/include/sqlext.h:2013: error: `LPWSTR' was not declared in this scope
C:/Dev-Cpp/include/sqlext.h:2013: error: `DWORD' was not declared in this scope
C:/Dev-Cpp/include/sqlext.h:2013: error: initializer expression list treated as compound expression
C:/Dev-Cpp/include/sqlext.h:2015: error: expected constructor, destructor, or type conversion before "TraceReturn"
C:/Dev-Cpp/include/sqlext.h:2015: error: expected `,' or `;' before "TraceReturn"
C:/Dev-Cpp/include/sqlext.h:2016: error: expected constructor, destructor, or type conversion before "TraceVersion"
C:/Dev-Cpp/include/sqlext.h:2016: error: expected `,' or `;' before "TraceVersion"
C:/Dev-Cpp/include/sqlext.h:2023: warning: `__stdcall__' attribute only applies to function types
C:/Dev-Cpp/include/sqlext.h:2023: error: `DWORD' was not declared in this scope
C:/Dev-Cpp/include/sqlext.h:2033: error: expected constructor, destructor, or type conversion before "ODBCSetTryWaitValue"
C:/Dev-Cpp/include/sqlext.h:2033: error: expected `,' or `;' before "ODBCSetTryWaitValue"
C:/Dev-Cpp/include/sqlext.h:2034: error: expected constructor, destructor, or type conversion before "ODBCGetTryWaitValue"
C:/Dev-Cpp/include/sqlext.h:2034: error: expected `,' or `;' before "ODBCGetTryWaitValue"
C:/Dev-Cpp/include/sqlext.h:2044: error: ISO C++ forbids declaration of `GUID' with no type
C:/Dev-Cpp/include/sqlext.h:2044: error: expected `;' before '*' token
C:/Dev-Cpp/include/sqlext.h:2045: error: `DWORD' does not name a type
C:/Dev-Cpp/include/sqlext.h:2047: error: ISO C++ forbids declaration of `WCHAR' with no type
C:/Dev-Cpp/include/sqlext.h:2047: error: expected `;' before '*' token
C:/Dev-Cpp/include/sqlext.h:2048: error: ISO C++ forbids declaration of `CHAR' with no type
C:/Dev-Cpp/include/sqlext.h:2048: error: expected `;' before '*' token
C:/Dev-Cpp/include/sqlext.h:2051: error: ISO C++ forbids declaration of `WCHAR' with no type
C:/Dev-Cpp/include/sqlext.h:2051: error: expected `;' before '*' token
C:/Dev-Cpp/include/sqlext.h:2052: error: ISO C++ forbids declaration of `CHAR' with no type
C:/Dev-Cpp/include/sqlext.h:2052: error: expected `;' before '*' token
C:/Dev-Cpp/include/sqlext.h:2056: error: expected constructor, destructor, or type conversion before "FireVSDebugEvent"
C:/Dev-Cpp/include/sqlext.h:2056: error: expected `,' or `;' before "FireVSDebugEvent"
In file included from C:/Dev-Cpp/include/sqlext.h:2066,
from main.cpp:5:
C:/Dev-Cpp/include/sqlucode.h:280: error: `SQLHWND' has not been declared
C:/Dev-Cpp/include/sqlucode.h:286: error: ISO C++ forbids declaration of `hwnd' with no type
C:/Dev-Cpp/include/sqlucode.h:647: error: `SQLHWND' has not been declared
C:/Dev-Cpp/include/sqlucode.h:653: error: ISO C++ forbids declaration of `hwnd' with no type
main.cpp: In function `int main(int, char**)':
main.cpp:13: error: `SQLHandle' undeclared (first use this function)
main.cpp:13: error: (Each undeclared identifier is reported only once for each function it appears in.)
main.cpp:13: error: expected `;' before "hdlEnv"
main.cpp:18: error: expected `,' or `;' before "char"
main.cpp:23: error: `hdlEnv' undeclared (first use this function)
main.cpp:24: error: `SQL_OV_ODBC30' undeclared (first use this function)
main.cpp:25: error: `hdlConn' undeclared (first use this function)
main.cpp:26: error: `userID' undeclared (first use this function)
main.cpp:27: error: `hdlDbc' undeclared (first use this function)
main.cpp:27: error: `hdlStmt' undeclared (first use this function)
main.cpp:28: error: `stmt' undeclared (first use this function)
main.cpp:33: error: `SQL_SUCCEEDED' undeclared (first use this function)
main.cpp:35: error: `DT_STRING' undeclared (first use this function)
make.exe: *** [main.o] Error 1
Execution terminated
Hey,
I have never really used odbc from C (usually any database stuff I do from C#). I found a odbc project that you should be able to include in your project and get it to work: http://libodbcxx.sourceforge.net/
According to the description it builds in linux and win32 so it should be usable. I have not actually used this before so im not sure if you will run into any issues or not. Just the best suggestion I could find. Good Luck.
__________________ Compilr.com Owner and Developer