0
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim con As New SqlConnection
Dim cmd As New SqlCommand
con.ConnectionString = "Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database1.mdf;Integrated Security=True;User Instance=True"
''cmd.CommandText = "insert into data values('" + TextBox1.Text + "','" + TextBox2.Text + "','" + TextBox2.Text + "')"
cmd.Connection = con
cmd.CommandText = "insert into db1(id,name) values ('" + TextBox1.Text + "','" + TextBox2.Text + "')"
con.Open()
cmd.ExecuteNonQuery()
con.Close()
End Sub
這是一個WinForm或ASP.NET應用程序? – Steve