如何用VB向SQL数据库中添加记录
1个回答
推荐于2017-12-15 · 知道合伙人软件行家
关注
展开全部
Sub 添加_OnClick(ByVal sender As Object, ByVal e As EventArgs)
Dim SqlConn As New SqlConnection
SqlConn.ConnectionString = "Persist Security Info=true;Initial Catalog=Data;uid=sa;pwd=123456;Data Source=.;"
SqlConn.Open()
Dim SqlCmd As New SqlCommand
SqlCmd.Connection = SqlConn
SqlCmd.CommandText = "Insert into #table (客户编号,性别,电话,电子信箱,地址,住址)values('" & 客户编号.Text & "','" & 性别.Text & "','" & 电话.Text& "','" & 电子信箱.Text & "'," & 地址.Text & ",'" & 住址.Text & "')"
SqlCmd.ExecuteNonQuery()
SqlConn.Close()
End Sub
Dim SqlConn As New SqlConnection
SqlConn.ConnectionString = "Persist Security Info=true;Initial Catalog=Data;uid=sa;pwd=123456;Data Source=.;"
SqlConn.Open()
Dim SqlCmd As New SqlCommand
SqlCmd.Connection = SqlConn
SqlCmd.CommandText = "Insert into #table (客户编号,性别,电话,电子信箱,地址,住址)values('" & 客户编号.Text & "','" & 性别.Text & "','" & 电话.Text& "','" & 电子信箱.Text & "'," & 地址.Text & ",'" & 住址.Text & "')"
SqlCmd.ExecuteNonQuery()
SqlConn.Close()
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询