3个回答
展开全部
记得引用微软的控件Microsoft ActoveX Date Objects 2.6 Library
Dim con As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim constr As String
Dim sqlstr As String
constr = "driver={sql server};server=你的服务器;uid=用户名;pwd=密码;database=数据库"
con.ConnectionString = constr
con.Open
sqlstr = "insety into table (field,field1) values('" & text1.text & "','" & text2.text & "')"
SQLconn.Execute sqlstr
Dim con As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim constr As String
Dim sqlstr As String
constr = "driver={sql server};server=你的服务器;uid=用户名;pwd=密码;database=数据库"
con.ConnectionString = constr
con.Open
sqlstr = "insety into table (field,field1) values('" & text1.text & "','" & text2.text & "')"
SQLconn.Execute sqlstr
展开全部
Dim lj As String = "Data Source=数据库;Initial Catalog=服务器;Persist Security Info=True;User ID=用户名;Password=密码"
Dim con As New Data.SqlClient.SqlConnection(lj)
Dim sql2 As String = "select * from tblworkcenter where workcentercode=" + "'" + WorkCenterCode + "'"
con.Open()
Dim cmd As New Data.SqlClient.SqlCommand(sql2, con)
Dim myreader As Data.SqlClient.SqlDataReader = cmd.ExecuteReader
If myreader.Read() Then
base.Alert("Data duplication, please re-enter")
Exit Sub
End If
con.Close()
Dim con As New Data.SqlClient.SqlConnection(lj)
Dim sql2 As String = "select * from tblworkcenter where workcentercode=" + "'" + WorkCenterCode + "'"
con.Open()
Dim cmd As New Data.SqlClient.SqlCommand(sql2, con)
Dim myreader As Data.SqlClient.SqlDataReader = cmd.ExecuteReader
If myreader.Read() Then
base.Alert("Data duplication, please re-enter")
Exit Sub
End If
con.Close()
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
insert语句
数据库方面的我建议你去查别人的模块
一般写代码的都会把这个建成一个模块
以后程序中使用的时候可以直接提用
数据库方面的我建议你去查别人的模块
一般写代码的都会把这个建成一个模块
以后程序中使用的时候可以直接提用
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询