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

Recommended Answers

All 4 Replies

Is ID a string?

it probably needs quote marks round it too or it will try and think its a column name

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

then do just that :)

Have a guess.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.