Box

Box

  • NA
  • 51
  • 32.3k

Entering data into access database

Jul 20 2011 10:41 AM
Im still in the learning stages and have spent the majority of today searching around trying to follow tutorials or get information on how to simply use sql (i know the sql 'language' as have worked with databases a long time via php,vba and access but c# is new to me and not as simple to conenct to (althoguh will be once i understand how to!)


The Error i get is: An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in system.data.dll
Additional information: System error.

my code is


{




private void button1_Click(object sender, System.EventArgs e)string istring = @"INSERT INTO tblUsers(username, distance) VALUES('Test',54321);";SqlConnection conn =


conn.Open();


new SqlConnection(@"Data Source=L:\testing\in the distance\ITD.mdb");

SqlCommand cmd =


new SqlCommand(istring, conn);//  this is where it debugscmd.ExecuteNonQuery();




if (conn != null)
{
conn.Close();
}
}

Thanx

Answers (11)