database problem

Please support our C# advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Nov 2008
Posts: 27
Reputation: ayi_102 is an unknown quantity at this point 
Solved Threads: 0
ayi_102 ayi_102 is offline Offline
Light Poster

database problem

 
0
  #1
Jan 6th, 2009
mydb thedb = new mydb();
            MyGlobal oapp = new MyGlobal();

            //define the reader
            System.Data.OleDb.OleDbDataReader theReader = null;

            //defining sql
            string _sql = "SELECT * FROM searchtest WHERE ID = " +  _ddsearch;
            string _sqlupdate = "";

            //execute the reader
            theReader  = thedb.SQLExecute_Reader(_sql);

this code is try to grab the value from _ddsearch variable
if the value is number it works
but if it is string, theReader return null

this is the problem
string _sql = "SELECT * FROM searchtest WHERE ID = " + _ddsearch;
the code above is for number

how do you make
ID = " + _ddsearch; to get variable value as string

I try to put another qutation mark but it is still wrong
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 2,065
Reputation: Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice 
Solved Threads: 256
Featured Poster
Ramy Mahrous's Avatar
Ramy Mahrous Ramy Mahrous is offline Offline
Postaholic

Re: database problem

 
0
  #2
Jan 7th, 2009
Is ID a string?
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,735
Reputation: LizR has a spectacular aura about LizR has a spectacular aura about 
Solved Threads: 186
LizR LizR is offline Offline
Posting Virtuoso

Re: database problem

 
0
  #3
Jan 7th, 2009
it probably needs quote marks round it too or it will try and think its a column name
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 27
Reputation: ayi_102 is an unknown quantity at this point 
Solved Threads: 0
ayi_102 ayi_102 is offline Offline
Light Poster

Re: database problem

 
0
  #4
Jan 7th, 2009
the problem is that theReader return string and the variable return int(number)
which is i have to format it to string to make the reader read
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,735
Reputation: LizR has a spectacular aura about LizR has a spectacular aura about 
Solved Threads: 186
LizR LizR is offline Offline
Posting Virtuoso

Re: database problem

 
0
  #5
Jan 7th, 2009
then do just that

Have a guess.
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
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