如:
Private Sub Commmand1_Click()
Dim adoConn As New ADODB.Connection
Dim adoConStr AS String
Dim mySQL AS String
adoConStr="Provider=SQLOLEDB.1Persist Security Info=TrueUser ID=saPassword=123
Data Source =服务器名Initial Catalog=xsda"
mySQL="INSERT INTO cj(yw,sx,wl,ID) Values ('"+Text1+"','"+Text2+"','"+text3+"',005)"
adoConn.Open adoConStr
adoConn.Execute mySQL
...
据我观察你录入是成绩数据,如果数据字段是“数值”型的话,那SQL语句就要变一下了...
一是数值转换,二是保留了2位小数
mySQL="INSERT INTO cj(yw,xs,wl,ID) Values ("
mySQL=mySQL + Format(text1,"#0.00")+","
mySQL=mySQL + Format(text2,"#0.00")+","
mySQL=mySQL + Format(text3,"#0.00")+",005)"
在执行插入的SQL 语句
adoConn.Execute mySQL
End Sub
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)