vb书签无效
DimobjconAsNewADODB.ConnectionDimobjrsAsNewADODB.RecordsetDimstrConnAsStringDimstr1As...
Dim objcon As New ADODB.Connection
Dim objrs As New ADODB.Recordset
Dim strConn As String
Dim str1 As String
Private Sub Form_Load()
strConn = "Provider=SQLOLEDB.1;User ID=sa;password=19890425;Initial Catalog=gui;Data Source=jujumao"
objcon.Open strConn
objrs.Open "student", objcon, 3, 3
Set DataGrid1.DataSource = objrs
With DataGrid1
.Columns(0).Caption = "学号"
.Columns(1).Caption = "姓名"
.Columns(2).Caption = "性别"
.Columns(3).Caption = "年龄"
.Columns(4).Caption = "系"
End With
End Sub
Private Sub Command1_Click()
objrs.AddNew
objrs.Fields("sno") = Text1.Text
objrs.Fields("sname") = Text2.Text
objrs.Fields("ssex") = Text3.Text
objrs.Fields("sage") = Text4.Text
objrs.Fields("sdept") = Text5.Text
objrs.Update
DataGrid1.Refresh
End Sub
Private Sub Command2_Click()
If (vbYes = MsgBox("真的要删除吗", vbYesNo + vbQuestion, "删除提示框")) Then
objrs.Delete
objrs.MoveNext
If objrs.EOF Then objrs.MoveLast
End If
End Sub
'str1 = "INSERT INTO student(sno,sname,ssex,sage,sdept) VALUES( ' " & Text1 & " ', ' " & Text2 & " ',' " & Text3 & " ', ' " & Text4 & " ' , ' " & Text5 & " ' ) "
'objcon.Execute str1
删除操作时不提示书签无效,插入时提示书签无效为什么呢,帮我小改一下,谢谢了
。。。。。我就是由你那个语句改过来的,应该也不行的嘿嘿,再帮我想想 展开
Dim objrs As New ADODB.Recordset
Dim strConn As String
Dim str1 As String
Private Sub Form_Load()
strConn = "Provider=SQLOLEDB.1;User ID=sa;password=19890425;Initial Catalog=gui;Data Source=jujumao"
objcon.Open strConn
objrs.Open "student", objcon, 3, 3
Set DataGrid1.DataSource = objrs
With DataGrid1
.Columns(0).Caption = "学号"
.Columns(1).Caption = "姓名"
.Columns(2).Caption = "性别"
.Columns(3).Caption = "年龄"
.Columns(4).Caption = "系"
End With
End Sub
Private Sub Command1_Click()
objrs.AddNew
objrs.Fields("sno") = Text1.Text
objrs.Fields("sname") = Text2.Text
objrs.Fields("ssex") = Text3.Text
objrs.Fields("sage") = Text4.Text
objrs.Fields("sdept") = Text5.Text
objrs.Update
DataGrid1.Refresh
End Sub
Private Sub Command2_Click()
If (vbYes = MsgBox("真的要删除吗", vbYesNo + vbQuestion, "删除提示框")) Then
objrs.Delete
objrs.MoveNext
If objrs.EOF Then objrs.MoveLast
End If
End Sub
'str1 = "INSERT INTO student(sno,sname,ssex,sage,sdept) VALUES( ' " & Text1 & " ', ' " & Text2 & " ',' " & Text3 & " ', ' " & Text4 & " ' , ' " & Text5 & " ' ) "
'objcon.Execute str1
删除操作时不提示书签无效,插入时提示书签无效为什么呢,帮我小改一下,谢谢了
。。。。。我就是由你那个语句改过来的,应该也不行的嘿嘿,再帮我想想 展开
1个回答
展开全部
语句应该是没错的了,是不是你的字段类型不符合呀?如果类型没错的话,那我也没办法咯~~
====================================
'str1 = "INSERT INTO student(sno,sname,ssex,sage,sdept) VALUES( ' " & Text1.Text & " ', ' " & Text2.Text & " ',' " & Text3.Text & " ', ' " & Text4.Text & " ' , ' " & Text5.Text & " ' ) "
应该是这样吧 你试试
====================================
'str1 = "INSERT INTO student(sno,sname,ssex,sage,sdept) VALUES( ' " & Text1.Text & " ', ' " & Text2.Text & " ',' " & Text3.Text & " ', ' " & Text4.Text & " ' , ' " & Text5.Text & " ' ) "
应该是这样吧 你试试
AiPPT
2024-09-19 广告
2024-09-19 广告
随着AI技术的飞速发展,如今市面上涌现了许多实用易操作的AI生成工具1、简介:AiPPT: 这款AI工具智能理解用户输入的主题,提供“AI智能生成”和“导入本地大纲”的选项,生成的PPT内容丰富多样,可自由编辑和添加元素,图表类型包括柱状图...
点击进入详情页
本回答由AiPPT提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询