[求助]自编一个利用ADO编程的例子,有个头疼的问题
本帖最后由 作者 于 2002-12-14 16:56:06 编辑Private Sub ComboBox1_Click()
Dim cn As Connection
Set cn = New Connection
cn.Open "PROVIDER=Microsoft.Jet.OLEDB.3.51;Data Source=d:\cf.mdb;"
Dim cmd As New ADODB.Command
Set cmd.ActiveConnection = cn
cmd.CommandText = "select b,h,name from cf1 where name='" & ComboBox1.Text & "'"
Dim rst As New ADODB.Recordset
rst.CursorLocation = adUseClient
rst.Open cmd, , adOpenStatic, adLockBatchOptimistic
Do While Not rst.EOF
UserForm1.TextBox1.Text = rst("h")
UserForm1.TextBox2.Text = rst("b")
rst.MoveNext
Loop
rst.Clone
End Sub
Private Sub CommandButton1_Click()
UserForm1.Hide
Dim pt As Variant
pt = ThisDrawing.Utility.GetPoint(, "拾取插入点:")
h = Val(UserForm1.TextBox1.Text)
b = Val(UserForm1.TextBox2.Text)
Dim ax1(0 To 2) As Double
Dim ax2(0 To 2) As Double
Dim ax3(0 To 2) As Double
Dim ax4(0 To 2) As Double
ax1(0) = pt(0)
ax1(1) = pt(1)
ax1(2) = pt(2)
ax2(0) = pt(0) + b
ax2(1) = pt(1)
ax2(2) = pt(2)
ax3(0) = pt(0)
ax3(1) = pt(1) + h
ax3(2) = pt(2)
ax4(0) = pt(0) + b
ax4(1) = pt(1) + h
ax4(2) = pt(2)
Dim linea, lineb, linec, lined As AcadLine
Set linea = ThisDrawing.ModelSpace.AddLine(ax1, ax2)
Set lineb = ThisDrawing.ModelSpace.AddLine(ax2, ax3)
Set linec = ThisDrawing.ModelSpace.AddLine(ax3, ax4)
Set lined = ThisDrawing.ModelSpace.AddLine(ax4, ax1)
End Sub
Private Sub UserForm_Initialize()
ComboBox1.AddItem "10*20"
ComboBox1.AddItem "15*30"
ComboBox1.AddItem "20*40"
End Sub
执行以后出现这句提示:实时错误‘-2147217904(80040阿0)’:至少一个参数没有被指定值。
因有窗口,再还有一个ACCESS数据库,将之压缩上传
你的数据库结构有问题
数据库的三个字段。字段名分别为“字段1”、“字段2”、“字段3”。而你想要的字段名应该是“name”、“h”、“b”,只是你把它们作为了表的第一条记录。修改的方法:在ACCESS中打开数据库,右击表cf1,选择“设计”,把字段改过来就行了。当然,真正实用的数据库还应该设置字段的数据类型。
"select 字段1,字段2,字段3 from cf1 where name=
金版主这句SQL大概不好吧
如果不愿改动数据库结构,SQL语句应该这样写:Select 字段1 As name,字段2 As h,字段3 As b where name=......
昏!忙中出错。是我自己太粗心啦!谢谢各位!
谢谢楼主的分享!收藏备用。
页:
[1]