Urgent Pls Help: My codes are in errors!

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Aug 2005
Posts: 3
Reputation: charlie_help is an unknown quantity at this point 
Solved Threads: 0
charlie_help charlie_help is offline Offline
Newbie Poster

Urgent Pls Help: My codes are in errors!

 
0
  #1
Aug 20th, 2005
I want to fetch data from SQL Server 2000 using tcp/ip connection
and display on the client.

Q : How do i fetch data from SQL Server 2000 and put the data on a combo box.
Q: My server user interface will have "Fetch" button ?

Client User Interface:
  1. ___________________________
  2. Category: |
  3. o Books o Stationey | } Radio Buttons: If Books is choose, books items will display
  4. o accessories o I.T Stuffs | }
  5. |
  6. _________ |
  7. Item: |____|_^_|------------------------> {ComboBox} The data is retrieved /fetch from SQL Server 2000 by tcp/ip
  8. |
  9. |
  10. |
  11. |
  12. |
  13. |
  14. -------------------------------------
My server program software is Ms Visual Studio.NET 2003.
Lanuage is C++



Appreciate the kind help recieved.


Q1) COULD YOU PLS CHECK THE FOLLOWING C++ CODES:

  1. //databaseDlg.cpp
  2.  
  3.  
  4. #using <mscorlib.dll>
  5. #using <System.dll>
  6. #using <System.Data.dll>
  7.  
  8. void CdatabaseDlg::CreateMySqlDataReader(char* mySelectQuery, char* myConnectionString)
  9. {
  10. SqlConnection* myConnection = new SqlConnection(myConnectionString "provider=sqloledb;Data Source=local;Initial Catalog=PRODUCT;User Id=temp;Password=password;");
  11.  
  12. SqlCommand* myCommand = new SqlCommand(mySelectQuery "SELECT ITEM FROM PRODUCT", myConnection);
  13.  
  14. myConnection->Open();
  15. SqlDataReader* myReader = myCommand->ExecuteReader(CommandBehavior::CloseConnection);
  16. while(myReader->Read())
  17. {
  18. Console::WriteLine(myReader->GetString(0));
  19. }
  20. myReader->Close();
  21. //Implicitly closes the connection because CommandBehavior::CloseConnection was specified.
  22. };
____________________________________________________________________________________________________

  1. //databaseDlg.h
  2. //Declare the method here
  3.  
  4. public:
  5.  
  6. void CreateMySqlDataReader(char* mySelectQuery, char* myConnectionString);


____________________________________________________________________________________________________
  1. //database.cpp
  2. //Call the Method here
  3.  
  4. void CdatabaseDlg::CreateMySqlDataReader(char* mySelectQuery, char* myConnectionString)
  5. {
  6. CdatabaseDlg call;
  7. call.CreateMySqlDataReader("SELECT ITEM FROM PRODUCT",
  8. "provider=sqloledb;Data Source=local;Initial Catalog=MENU;User Id=temp;Password=password");
  9. }

_____________________________________________________________________________________________________
Errors: Leading to database.cpp and databaseDld.cpp


c:\Documents and Settings\Student\Desktop\database\databaseDlg.cpp(9): fatal error C1190: managed targeted code requires '#using <mscorlib.dll>' and '/clr' option
c:\documents and settings\student\desktop\database\database.cpp(84): warning C4717: 'CdatabaseDlg::CreateMySqlDataReader' : recursive on all control paths, function will cause runtime stack overflow


Problem:
Q2) DEBUGGING PROBLEM: ABOVE ERRORS
Q3) IM NOT SURE HOW TO BIND DATA INTO COMBOBOX IN C++ LANG
____________________________________________________________________________________________________

Data to bind to ComboBox:
___________________________

Inside the comboBox Method:

  1. void CdatabaseDlg::OnCbnSelchangeCombo1()
  2. {
  3. //Create an array to store the data.
  4.  
  5. String name[]={"","","","","","","","","","","","","","",""};
  6.  
  7. //How to Bind Data to comboBox???
  8.  
  9. ComboBox.
  10.  
  11. }



ANYONE PLS HELP!

From
Decruz
Last edited by Dave Sinkula; Aug 20th, 2005 at 4:31 pm. Reason: Added code tags.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 10
Reputation: Sutanu is an unknown quantity at this point 
Solved Threads: 0
Sutanu Sutanu is offline Offline
Newbie Poster

Re: Urgent Pls Help: My codes are in errors!

 
0
  #2
Aug 20th, 2005
I do not understand why you want to directly use a tcp/ip connection for fetching the data.

Rather creater a dsn to be used over the network to access the sqlserver data.

From your Cpp file use Sqlconnect using the dsn name. Prepare the stmt and exceute the sql statement to retrieve the data.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 3
Reputation: charlie_help is an unknown quantity at this point 
Solved Threads: 0
charlie_help charlie_help is offline Offline
Newbie Poster

Re: Urgent Pls Help: My codes are in errors!

 
0
  #3
Aug 21st, 2005
Hi Sutanu!

I'm using tcp/ip to transfer those data from my sql server 2000 to my client.

You suggest that to use:

Rather creater a dsn to be used over the network to access the sqlserver data.
From your Cpp file use Sqlconnect using the dsn name. Prepare the stmt and exceute the sql statement to retrieve the data.

Q1) How do i do that?
Q2) Can you provide some source codes?

Thank You
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC