private void button1_Click(object sender, System.EventArgs e)
{
button1.Focus();try
{
SqlConnection con=new SqlConnection("server=gidafi;uid=sa;pwd=sa;database=pubs");
SqlCommand sqlcom=new SqlCommand("select * from jobs",con);
SqlDataAdapter sqldpt=new SqlDataAdapter();
sqldpt.SelectCommand=sqlcom;
DataSet ds=new DataSet();
con.Open();
sqldpt.Fill(ds,"jobs");
textBox1.DataBindings("Text", ds ,"job_id");
textBox2.DataBindings.Add("Text", ds ,"job_des");
textBox3.DataBindings.Add("Text", ds ,"min_lvl");
textBox4.DataBindings.Add("Text", ds ,"max_lvl");
con.Close();
}
catch(Exception f){MessageBox.Show("what"+f);}
__________________________________________________
I'm using SQL2000 server database
exception generated by the code is WhatSystem.ArgumentException;Cannot bind to property or column job_id Datasource
AnttiRank #9,295 · 208 pointsPosted Dec 7, 2005, 6:07 AM EST
What kind of a database you use? Slq-classes are only for Microsoft SqlServer databases. If you use any other database than SqlServer (Access for example), you must use OleDb-classes instead, and appropriate connection string when creating OleDbConnection.
Double check database table and column names.
This line seems to be wrong:
textBox1.DataBindings("Text", ds ,"job_id");