1
我正在研究班加羅爾大學規定的項目。我使用vb.net 2008作爲前端,Ms Access 2007作爲後端。當我嘗試運行該程序時,出現錯誤ConnectionString屬性尚未初始化。ConnectionString屬性尚未初始化
這裏是我曾經用過
private Sub Add_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Add.Click
Dim con As New OleDb.OleDbConnection
Dim cmd As New OleDb.OleDbCommand
Dim dbProvider As String
Dim dbSource As String
dbProvider = "Provider=Microsoft.Jet.OLEDB.4.0;"
dbSource = "DataSource=C:\My Project\project.mdb"
con.ConnectionString = dbProvider & dbSource
con = New OleDb.OleDbConnection
con.Open()
cmd.Connection = con
cmd.CommandText = "Insert Into Application(appno, mname, age, gender, height, weight, address, purpose, bmi, mailid, phoneno, paymnet)" & _
"Values('" & Me.appno.Text & "', '" & Me.mname.Text & "', '" & Me.age.Text & "', '" & Me.gender.Text & "', '" & _
Me.mheight.Text & "', '" & Me.weight.Text & "', '" & Me.address.Text & "', '" & Me.purpose.Text & "', '" & _
Me.bmi.Text & "', '" & Me.mailid.Text & "', '" & Me.phoneno.Text & "', '" & Me.payment.Text & "')"
cmd.ExecuteNonQuery()
con.Close()
End Sub
so可以做些什麼先生? –
@MadanRaj刪除指定的行'con = New OleDb.OleDbConnection',它不應該在那裏。 –
那麼先生可以做些什麼?我正在理清這一點。 –