inser into table1 (filed1,field2) values (str1,str2)
用INSERT INTO 语句或是 updata语句UP~!!!
Dim cn As New ADODB.ConnectionPrivate Sub Command1_Click() Dim strSQL As String strSQL = "Insert Into table (field1,field2) values ('" & text1.Text & "','" & text1.Text & "')" cn.Execute strSQL MsgBox "写入成功", vbExclamation End SubPrivate Sub Form_Load() cn.Provider = "SQLOLEDB" cn.Open "Driver={SQL Server};Server=Develop;Database=Test;Uid=SA;Pwd=;" End SubPrivate Sub Form_Unload(Cancel As Integer) cn.Close Set cn = Nothing End Sub
Dim strSQL As String
strSQL = "Insert Into table (field1,field2) values ('" & text1.Text & "','" & text1.Text & "')"
cn.Execute strSQL
MsgBox "写入成功", vbExclamation
End SubPrivate Sub Form_Load()
cn.Provider = "SQLOLEDB"
cn.Open "Driver={SQL Server};Server=Develop;Database=Test;Uid=SA;Pwd=;"
End SubPrivate Sub Form_Unload(Cancel As Integer)
cn.Close
Set cn = Nothing
End Sub
UP
看看有几分了,我也无聊中
http://www.csdn.net/expert/topic/821/821499.xml?temp=.5582544
str = "窗体上输入的数据"Set CurrentDB = OpenDatabase(AppDbName, True, False, ";pwd= ****")
str = "Insert Into" & "表名" & "values(字段名1,字段名2 , ,...,字段名n)"
CurrentDB.Execute strSql
CurrentDB.Close
Set CurrentDB = Nothing