喜逢好友
Public con_str As String = "provider=microsoft.jet.oledb.4.0;data source=|datadirectory|\damyar.mdb;"
Dim con As New OleDbConnection
Dim com As New OleDbCommand
con.ConnectionString = con_str
com.CommandType = CommandType.Text
com.CommandText = "INSERT into Talgih VALUES(@ID_talgih,@ID_key,@talgih_type,@talgih_date_y,@talgih_date_m,@talgih_date_d,@talgih_nobat,@ID_sperm,@sh_gav_nar,@gav_laktasion,@mamoor)"
com.Parameters.AddWithValue("ID_talgih", txt_ID_talgih.Text)
com.Parameters.AddWithValue("ID_key", txt_ID_key)
com.Parameters.AddWithValue("talgih_type", s)
com.Parameters.AddWithValue("talgih_date_y", txt_talgih_date_y)
com.Parameters.AddWithValue("talgih_date_m", txt_talgih_date_m)
com.Parameters.AddWithValue("talgih_date_d", txt_talgih_date_d)
com.Parameters.AddWithValue("talgih_nobat", txt_talgih_nobat)
com.Parameters.AddWithValue("ID_sperm", txt_ID_sperm)
com.Parameters.AddWithValue("sh_gav_nar", txt_sh_gav_nar)
com.Parameters.AddWithValue("gav_laktasion", txt_gav_laktasion)
com.Parameters.AddWithValue("mamoor", txt_mamoor)
con.Open()
com.ExecuteNonQuery()
con.Close()
当我运行这个程序,我看到的错误(的ExecuteNonQuery:Connection属性尚未初始化)