在aspx.vb文件連接字符串的數據源錯誤
Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
Dim con As New OleDbConnection("Provider= SQLOLEDB.1;Integrated Security=true; data source=myserver; ")
Dim cmd As New OleDbCommand
cmd.Connection = con
cmd.CommandText = "Insert into demo.dbo.masters1 values ('" & TextBox1.Text & " ," & TextBox4.Text & " , " & TextBox3.Text & " ')"
con.Open()
If (cmd.ExecuteNonQuery() > 0) Then
Label1.BorderColor = Drawing.Color.Aquamarine
Else
Label1.BorderColor = Drawing.Color.Black
End If
con.Close()
End Sub
我使用Windows身份驗證。
服務器已啓動並正在運行。
我也試過:
Dim con As New OleDbConnection("Provider= SQLOLEDB.1;Integrated Security=true; data source=C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\database_name.mdf; ")
不過,我發現了以下錯誤:
No error message available, result code: DB_E_ERRORSOCCURRED(0x80040E21).
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.OleDb.OleDbException: No error message available, result code: DB_E_ERRORSOCCURRED(0x80040E21).
哪條線會導致錯誤? – techspider
表格母版1有多少列?你想要將一個連接字符串插入一列還是將三個字符串插入三列? –
你迫切需要參數化你的查詢。這是編碼的方式是SQL注入的教科書示例。 –