hi,
i am a beginner in programming and new to c# as well.
i am using c# to access an access database that has one table named people.
the table has three columns: firstName lastName TZ.
i successfully wrote a method that inserts a new row to the table by using
OleDb objects.
Now i am trying to write a method that locates the appropriate TZ value
upon receiving as input a firstName and lastName.
i wrote this:
string constring = @"Provider=Micr osoft.Jet.OLEDB .4.0; User Id=; Password=; Data Source=Db1.mdb" ;
string sqls = "SELECT TZ FROM People WHERE firstName ='" + fname.Text + "' AND lastName ='" + lname.Text + "' ";
where fname.Text amd lastName.Text are text fields on my form which contain the use input on the name he wants to find the TZ for.
then i wrote:
Myconnection = new OleDbConnection (constring);
Myconnection.Op en();
OleDbCommand cmd = new OleDbCommand(sq ls, Myconnection);
OleDbDataReader dataread = cmd.ExecuteRead er();
and here i got stuck since i wasnt able to find any method that simply submits
my sql query and returns the value of that query.
the connection to the database works perfectly fine.
all help will be appreciated :)
thank you
i am a beginner in programming and new to c# as well.
i am using c# to access an access database that has one table named people.
the table has three columns: firstName lastName TZ.
i successfully wrote a method that inserts a new row to the table by using
OleDb objects.
Now i am trying to write a method that locates the appropriate TZ value
upon receiving as input a firstName and lastName.
i wrote this:
string constring = @"Provider=Micr osoft.Jet.OLEDB .4.0; User Id=; Password=; Data Source=Db1.mdb" ;
string sqls = "SELECT TZ FROM People WHERE firstName ='" + fname.Text + "' AND lastName ='" + lname.Text + "' ";
where fname.Text amd lastName.Text are text fields on my form which contain the use input on the name he wants to find the TZ for.
then i wrote:
Myconnection = new OleDbConnection (constring);
Myconnection.Op en();
OleDbCommand cmd = new OleDbCommand(sq ls, Myconnection);
OleDbDataReader dataread = cmd.ExecuteRead er();
and here i got stuck since i wasnt able to find any method that simply submits
my sql query and returns the value of that query.
the connection to the database works perfectly fine.
all help will be appreciated :)
thank you
Comment