hi. I am working on a computing school project and have encountered the following problem when i was trying to link to a access 2007 database:
"ExecuteNonQuery: Connection property has not been initialized."
this is the code:
Dim connect_string As String = _
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\................"
Dim conn_db_extras_test2003 As New OleDb.OleDbConnection(connect_string)
conn_db_extras_test2003.Open()
Dim cmd As New OleDbCommand( _
"INSERT INTO cmm21.mdb (Team1, Team2, Map1, Map2, Map3, Score1, Score2, Score3, League, Size, Date) " & _
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")
cmd.Parameters.Add(New OleDbParameter("Team1", Form2.yourteam_textbox.Text))
cmd.Parameters.Add(New OleDbParameter("Team2", Form2.opponentteam_textbox.Text))
cmd.Parameters.Add(New OleDbParameter("Map1", map1_combobox.Text))
cmd.Parameters.Add(New OleDbParameter("Map2", map2_combobox.Text))
cmd.Parameters.Add(New OleDbParameter("Map3", map3_combobox.Text))
cmd.Parameters.Add(New OleDbParameter("Score1", score1_listbox.Text))
cmd.Parameters.Add(New OleDbParameter("Score2", score2_listbox.Text))
cmd.Parameters.Add(New OleDbParameter("Score3", score3_listbox.Text))
cmd.Parameters.Add(New OleDbParameter("League", league_combobox.Text))
cmd.Parameters.Add(New OleDbParameter("Size", size_combobox.Text))
cmd.Parameters.Add(New OleDbParameter("Date", date_label.Text))
cmd.ExecuteNonQuery()
conn_db_extras_test2003.Close()
conn_db_extras_test2003.Dispose()
I don't understand why this error keeps coming up and the project's deadline is close... , i really need some urgent help...
"ExecuteNonQuery: Connection property has not been initialized."
this is the code:
Dim connect_string As String = _
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\................"
Dim conn_db_extras_test2003 As New OleDb.OleDbConnection(connect_string)
conn_db_extras_test2003.Open()
Dim cmd As New OleDbCommand( _
"INSERT INTO cmm21.mdb (Team1, Team2, Map1, Map2, Map3, Score1, Score2, Score3, League, Size, Date) " & _
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")
cmd.Parameters.Add(New OleDbParameter("Team1", Form2.yourteam_textbox.Text))
cmd.Parameters.Add(New OleDbParameter("Team2", Form2.opponentteam_textbox.Text))
cmd.Parameters.Add(New OleDbParameter("Map1", map1_combobox.Text))
cmd.Parameters.Add(New OleDbParameter("Map2", map2_combobox.Text))
cmd.Parameters.Add(New OleDbParameter("Map3", map3_combobox.Text))
cmd.Parameters.Add(New OleDbParameter("Score1", score1_listbox.Text))
cmd.Parameters.Add(New OleDbParameter("Score2", score2_listbox.Text))
cmd.Parameters.Add(New OleDbParameter("Score3", score3_listbox.Text))
cmd.Parameters.Add(New OleDbParameter("League", league_combobox.Text))
cmd.Parameters.Add(New OleDbParameter("Size", size_combobox.Text))
cmd.Parameters.Add(New OleDbParameter("Date", date_label.Text))
cmd.ExecuteNonQuery()
conn_db_extras_test2003.Close()
conn_db_extras_test2003.Dispose()
I don't understand why this error keeps coming up and the project's deadline is close... , i really need some urgent help...