显示INVALID OBJECT NAME的SQL连接错误

时间:2012-11-24 12:54:18

标签: sql connection

我已完成了以下编码,但显示错误

无效的对象名称'sanket'

导入System.Data.SqlClient

Public Class Form1     Dim con As New SqlConnection     Dim cmd As New SqlCommand     Dim da As SqlDataAdapter     Dim ds作为新数据集     Dim str As String

Private Sub ConnectToSQL()
    Try
        con.ConnectionString = "Data Source=SA_N_KET-PC\SQLEXPRESS;Initial Catalog=repeat;Integrated Security=true;"
        con.Open()
    Catch ex As Exception
        MessageBox.Show("Error while connecting to SQL Server." & ex.Message)
    Finally
        'DoNothing.
    End Try
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    'TODO: This line of code loads data into the 'CryrptDataSet.sanket' table. You can move, or remove it, as needed.
    Me.SanketTableAdapter.Fill(Me.CryrptDataSet.sanket)
    ConnectToSQL()
End Sub
Public Sub exe()
    str = "insert into sanket(n)values ('" & TextBox1.Text & "')"
    da = New SqlDataAdapter(Str, con)
    da.Fill(ds, "sanket")
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    exe()
End Sub

结束班

0 个答案:

没有答案