已经连接好了ACCESS数据库,请问怎样将文本框的内容录入到ACCESS数据库中?

来源:百度知道 编辑:UC知道 时间:2024/06/23 17:24:23
我用的是VB!

不知道你用是的什么语言。
不同的语言都不一样的。
如ASP是
insert into 表名(字段1,字段2) values("&request("文本框1")&","&request("文本框2")&")而且还得根据你字段的类型来填。
如果是字符型的还得加上''.如'"&request("文本框名")&"'
如果是.NET的话其他和ASP差不多。就是把&改成+就行了。

Option Explicit
Private conn As ADODB.Connection
Private rs As ADODB.Recordset
Private Sub Command1_Click()
If LTrim$(RTrim$(Text1.Text)) = "" Then
MsgBox "学号不能为空!"
ElseIf Trim(Text2.Text) = "" Then
MsgBox "姓名不能为空为空!"
ElseIf Trim(Combo1.Text) = "" Then
MsgBox "性别不能为空!"
Else
inputuser
End If
End Sub
Private Sub inputuser() '添加学生模块
On Error GoTo ErrMsg
Dim txtSQL, i As String
txtSQL = "select * from 学生信息 where 学号='" & Trim(Text1.Text) & "'"
Set rs = New ADODB.Recordset
rs.CursorLocation = adUseClient