原码修改data改ado,在线急等,解决利结!!

bluesanke 2003-04-02 03:38:30
Option Explicit

Dim Mydb As Database
Dim Myrs1 As Recordset
Dim Myrs2 As Recordset

Private Sub Command1_Click()
Dim mrc As Recordset
Dim str1 As String, str2 As String

If Option1.Value = True Then
If Text1.Text = "" Then
MsgBox "请正确填写进库单号码!", vbOKOnly + vbExclamation, "信息提示"
Text1.SetFocus
Exit Sub
Else
Set Myrs1 = Mydb.OpenRecordset("select * from inlib where 进库单号码='" & Trim(Text1) & "'")
MSFlexGrid1.Clear
TableInit
If Myrs1.RecordCount >= 1 Then
Set Myrs2 = Mydb.OpenRecordset("select * from inlibdetail,goods where 进库单号码='" & Trim(Text1) & "' And GoodsID = 材料编码")
While Myrs2.EOF = False
MSFlexGrid1.Rows = MSFlexGrid1.Rows + 1
MSFlexGrid1.Row = MSFlexGrid1.Rows - 1
MSFlexGrid1.Col = 0
MSFlexGrid1.Text = Myrs1.Fields("进库单号码")
MSFlexGrid1.Col = 1
MSFlexGrid1.Text = Myrs1.Fields("发票号码")
MSFlexGrid1.Col = 2
MSFlexGrid1.Text = Myrs1.Fields("进库日期")
MSFlexGrid1.Col = 3
If IsNull(Myrs1.Fields("经办人")) Then
MSFlexGrid1.Text = ""
Else
MSFlexGrid1.Text = Myrs1.Fields("经办人")
End If
MSFlexGrid1.Col = 4
If IsNull(Myrs1.Fields("保管人")) Then
MSFlexGrid1.Text = ""
Else
MSFlexGrid1.Text = Myrs1.Fields("保管人")
End If
MSFlexGrid1.Col = 5
MSFlexGrid1.Text = Myrs2.Fields("goodsid")
MSFlexGrid1.Col = 6
MSFlexGrid1.Text = Myrs2.Fields("goodsname")
MSFlexGrid1.Col = 7
MSFlexGrid1.Text = Myrs2.Fields("type")
MSFlexGrid1.Col = 8
MSFlexGrid1.Text = Myrs2.Fields("unit")
MSFlexGrid1.Col = 9
MSFlexGrid1.Text = Myrs2.Fields("数量")
MSFlexGrid1.Col = 10
MSFlexGrid1.Text = Format(Myrs2.Fields("单价"), "#0.00")
MSFlexGrid1.Col = 11
MSFlexGrid1.Text = Format(Myrs2.Fields("金额"), "#0.00")
MSFlexGrid1.Col = 12
If IsNull(Myrs2.Fields("备注")) Then
MSFlexGrid1.Text = ""
Else
MSFlexGrid1.Text = Myrs2.Fields("备注")
End If
Myrs2.MoveNext
Wend
Myrs2.Close
Else
MsgBox "不存在这个进库单号码", vbOKOnly + vbExclamation, "信息提示"
Text1 = ""
Text1.SetFocus
Exit Sub
End If
Myrs1.Close
End If
End If
end sub
尤其是Set Myrs1 = Mydb.OpenRecordset("select * from inlib where 进库单号码='" & Trim(Text1) & "'")这句中的Mydb.OpenRecordset用ado怎么实现?!


...全文
12 点赞 收藏 6
写回复
6 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
zsgzsgzsg 2003-04-02
连接字符串:
1、"Driver={Microsoft ODBC for Oracle};Server=OracleServer.world;Uid=Username;Pwd=asdasd;"
2、"Provider=msdaora;Data Source=MyOracleDB;User Id=UserName;Password=asdasd;"
3、"Provider=OraOLEDB.Oracle;Data Source=MyOracleDB;User Id=Username;Password=asdasd;"
根据你自己的实际情况选择一个
回复
bluesanke 2003-04-02
谢谢大哥又来帮忙!
可是cnsstring="Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=" & App.Path & "\data\XXXX.mdb;" _
& "Persist Security Info=False"
'连接字符串,这相要根据你自己的实际情况来改一下。
我用的是oracle库怎么修改呀!很麻烦吗 ??
回复
bluesanke 2003-04-02
Myrs1.open "select * from inlib where 进库单号码='" & Trim(Text1) &"',cnn, adOpenDynamic, adLockPessimistic为什么运行到open就显示要求对象呀!另外我用的是oracle的库,cnn.ConnectionString = "driver={Microsoft Access Driver (*.mdb)};" & _
"dbq=" & App.Path & "\表名.mdb"
cnn.ConnectionTimeout = 30
这个怎么实现?????
回复
chenyu5188 2003-04-02
Option Explicit

Dim Mycn As new adodb.connection'数据库连接对象,用于打开数据库
Dim Myrs1 As new adodb.Recordset'记录集对象,用于存入记录的
Dim Myrs2 As new adodb.Recordset'记录集对象,用于存入记录的

Private Sub Command1_Click()
Dim cnstring as string'用于存放连接字符串的
cnsstring="Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=" & App.Path & "\data\XXXX.mdb;" _
& "Persist Security Info=False"
'连接字符串,这相要根据你自己的实际情况来改一下。
mycn.open cnstring
mycn.CursorLocation=adUseClient
If Option1.Value = True Then
If Text1.Text = "" Then
MsgBox "请正确填写进库单号码!", vbOKOnly + vbExclamation, "信息提示"
Text1.SetFocus
Exit Sub
Else
Myrs1.open "select * from inlib where 进库单号码='" & Trim(Text1) & "'",mycn
MSFlexGrid1.Clear
TableInit
If Myrs1.RecordCount >= 1 Then
Myrs2.open "select * from inlibdetail,goods where 进库单号码='" & Trim(Text1) & "' And GoodsID = 材料编码",mycn
While Myrs2.EOF = False
MSFlexGrid1.Rows = MSFlexGrid1.Rows + 1
MSFlexGrid1.Row = MSFlexGrid1.Rows - 1
MSFlexGrid1.Col = 0
MSFlexGrid1.Text = Myrs1.Fields("进库单号码")
MSFlexGrid1.Col = 1
MSFlexGrid1.Text = Myrs1.Fields("发票号码")
MSFlexGrid1.Col = 2
MSFlexGrid1.Text = Myrs1.Fields("进库日期")
MSFlexGrid1.Col = 3
If IsNull(Myrs1.Fields("经办人")) Then
MSFlexGrid1.Text = ""
Else
MSFlexGrid1.Text = Myrs1.Fields("经办人")
End If
MSFlexGrid1.Col = 4
If IsNull(Myrs1.Fields("保管人")) Then
MSFlexGrid1.Text = ""
Else
MSFlexGrid1.Text = Myrs1.Fields("保管人")
End If
MSFlexGrid1.Col = 5
MSFlexGrid1.Text = Myrs2.Fields("goodsid")
MSFlexGrid1.Col = 6
MSFlexGrid1.Text = Myrs2.Fields("goodsname")
MSFlexGrid1.Col = 7
MSFlexGrid1.Text = Myrs2.Fields("type")
MSFlexGrid1.Col = 8
MSFlexGrid1.Text = Myrs2.Fields("unit")
MSFlexGrid1.Col = 9
MSFlexGrid1.Text = Myrs2.Fields("数量")
MSFlexGrid1.Col = 10
MSFlexGrid1.Text = Format(Myrs2.Fields("单价"), "#0.00")
MSFlexGrid1.Col = 11
MSFlexGrid1.Text = Format(Myrs2.Fields("金额"), "#0.00")
MSFlexGrid1.Col = 12
If IsNull(Myrs2.Fields("备注")) Then
MSFlexGrid1.Text = ""
Else
MSFlexGrid1.Text = Myrs2.Fields("备注")
End If
Myrs2.MoveNext
Wend
Myrs2.Close
Else
MsgBox "不存在这个进库单号码", vbOKOnly + vbExclamation, "信息提示"
Text1 = ""
Text1.SetFocus
Exit Sub
End If
Myrs1.Close
End If
End If
end sub
回复
980 2003-04-02
Public cnn As ADODB.Connection
Public Myrs1,Myrs2 As ADODB.Recordset
Set cnn = New ADODB.Connection
cnn.ConnectionString = "driver={Microsoft Access Driver (*.mdb)};" & _
"dbq=" & App.Path & "\表名.mdb"
cnn.ConnectionTimeout = 30
cnn.CursorLocation = adUseClient
cnn.Open
Myrs1.open "select * from inlib where 进库单号码='" & Trim(Text1) &"',cnn, adOpenDynamic, adLockPessimistic
Myrs2.open "select * from inlibdetail,goods where 进库单号码='" & Trim(Text1) & "' And GoodsID = 材料编码",cnn, adOpenDynamic, adLockPessimistic

这是acces数据库别的一样
回复
bluesanke 2003-04-02
Option Explicit

Dim Mydb As Database
Dim Myrs1 As Recordset
Dim Myrs2 As Recordset

Private Sub Command1_Click()
Dim mrc As Recordset
Dim str1 As String, str2 As String

If Option1.Value = True Then
If Text1.Text = "" Then
MsgBox "请正确填写进库单号码!", vbOKOnly + vbExclamation, "信息提示"
Text1.SetFocus
Exit Sub
Else
Set Myrs1 = Mydb.OpenRecordset("select * from inlib where 进库单号码='" & Trim(Text1) & "'")
其实把上面这句改了就行!
回复
相关推荐
发帖

1187

社区成员

VB 数据库(包含打印,安装,报表)
申请成为版主
帖子事件
创建了帖子
2003-04-02 03:38
社区公告
暂无公告