Current location: Hot Scripts Forums » Programming Languages » C/C++ » C++ and MSSQL tutorials?


C++ and MSSQL tutorials?

Reply
  #1 (permalink)  
Old 03-14-08, 09:46 AM
scott2500uk's Avatar
scott2500uk scott2500uk is offline
Coding Addict
 
Join Date: Apr 2006
Posts: 275
Thanks: 2
Thanked 2 Times in 2 Posts
C++ and MSSQL tutorials?

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 03-17-08, 12:22 PM
Rapid Dr3am Rapid Dr3am is offline
Community VIP
 
Join Date: Jan 2004
Location: Liverpool, England
Posts: 752
Thanks: 0
Thanked 0 Times in 0 Posts
Shouldn't be to different.

How are you doing your connection now?
__________________
Placeholder, place signature here.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 03-25-08, 01:44 PM
scott2500uk's Avatar
scott2500uk scott2500uk is offline
Coding Addict
 
Join Date: Apr 2006
Posts: 275
Thanks: 2
Thanked 2 Times in 2 Posts
sorry for the delay in responce.

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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 04-01-08, 10:58 AM
manstard manstard is offline
New Member
 
Join Date: Mar 2008
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by scott2500uk View Post
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 04-01-08, 12:19 PM
zenox zenox is offline
Newbie Coder
 
Join Date: Feb 2008
Location: Nova Scotia, Canada
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
Here is a good tutorial on connecting to an ODBC database.
http://www.dreamincode.net/forums/showtopic21309.htm

With odbc you should be able to switch between MSSQL and MySql relatively simply. (Just by changing your connection string).
__________________
Compilr.com Owner and Developer
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #6 (permalink)  
Old 04-02-08, 10:56 AM
scott2500uk's Avatar
scott2500uk scott2500uk is offline
Coding Addict
 
Join Date: Apr 2006
Posts: 275
Thanks: 2
Thanked 2 Times in 2 Posts
Quote:
Originally Posted by manstard View Post
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.
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #7 (permalink)  
Old 04-02-08, 11:05 AM
scott2500uk's Avatar
scott2500uk scott2500uk is offline
Coding Addict
 
Join Date: Apr 2006
Posts: 275
Thanks: 2
Thanked 2 Times in 2 Posts
Quote:
Originally Posted by zenox View Post
Here is a good tutorial on connecting to an ODBC database.
http://www.dreamincode.net/forums/showtopic21309.htm

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #8 (permalink)  
Old 04-03-08, 08:53 AM
zenox zenox is offline
Newbie Coder
 
Join Date: Feb 2008
Location: Nova Scotia, Canada
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #9 (permalink)  
Old 05-11-09, 03:33 AM
squall283 squall283 is offline
New Member
 
Join Date: May 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Unhappy mssql

Hi All, did any one find a good tutorial for connecting c++ app to mssql. I am having the same task and I can't find any valuable information.
Thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump


All times are GMT -5. The time now is 10:06 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.