因为小弟赶时间,来不及学vc了,现有一vb代码,要求用vc做成dll,要求vb,vc能调用。
现在请大家帮个忙把dll做好发给我。[email protected]。
重酬500分(另外开贴送分).因为真的急,所以恳请大家帮忙。
代码很小的,而且很简单,只怪我来不及学vc了,
因为急,所以请大家在浏览此贴也顶一下,不要让它沉下去.谢谢.Public Function GetCardState(ByVal strServerIP As String, ByVal strUser As String, ByVal strPwd As String, ByVal strDataBase As String, ByVal strCardNo As String, Optional ByRef ErrStr As String) As Integer
Dim cnnmain As New ADODB.Connection
Dim rsCard As New ADODB.Recordset
On Error GoTo myErr
If strServerIP = "" Then Err.Raise -1000, "", "ServerIP can not Empty"
If strUser = "" Then Err.Raise -1001, "", "Login User can not Empty"
If strDataBase = "" Then Err.Raise -1002, "", "DataBase can not Empty"
If strCardNo = "" Then Err.Raise -1003, "", "CardNo can not Empty"
On Error Resume Next
With cnnmain
.CursorLocation = adUseServe
.ConnectionTimeout = 30
.CommandTimeout = 30
.Open "Provider=SQLOLEDB.1;Password=" & strPwd & ";Persist Security Info=True;User ID=" & strUser & ";Initial Catalog=" & strDataBase & ";Data Source=" & strServerIP
End With
If Err Then
Err.Clear
On Error GoTo myErr
Err.Raise "-1004", "", "DataBase Connect Error"
End If
rsCard.Open "select top 1 CardStatus from madmcard where cardno = '" & strCardNo & "'", cnnmain, adOpenKeyset, adLockReadOnly
If Err Then
Err.Clear
On Error GoTo myErr
Err.Raise "-1005", "", "SQL Run Error"
End If
If Not rsCard.EOF Then
Select Case rsCard.Fields("CardStatus") & ""
Case "正常":
GetCardState = 1
Case "挂失":
GetCardState = 2
Case "待发":
GetCardState = 3
Case "回收":
GetCardState = 4
Case "有卡销户":
GetCardState = 5
Case "挂失销户":
GetCardState = 6
Case Else: '其他卡状态
GetCardState = 999
End Select
Else
Err.Clear
On Error GoTo myErr
Err.Raise "-1006", "", "Can not Find the Card State"
End If
rsCard.Close
Set rsCard = Nothing
Set cnnmain = Nothing
Exit Function
myErr:
GetCardState = Err.Number
ErrStr = Err.Description
Set rsCard = Nothing
Set cnnmain = Nothing
End Function
现在请大家帮个忙把dll做好发给我。[email protected]。
重酬500分(另外开贴送分).因为真的急,所以恳请大家帮忙。
代码很小的,而且很简单,只怪我来不及学vc了,
因为急,所以请大家在浏览此贴也顶一下,不要让它沉下去.谢谢.Public Function GetCardState(ByVal strServerIP As String, ByVal strUser As String, ByVal strPwd As String, ByVal strDataBase As String, ByVal strCardNo As String, Optional ByRef ErrStr As String) As Integer
Dim cnnmain As New ADODB.Connection
Dim rsCard As New ADODB.Recordset
On Error GoTo myErr
If strServerIP = "" Then Err.Raise -1000, "", "ServerIP can not Empty"
If strUser = "" Then Err.Raise -1001, "", "Login User can not Empty"
If strDataBase = "" Then Err.Raise -1002, "", "DataBase can not Empty"
If strCardNo = "" Then Err.Raise -1003, "", "CardNo can not Empty"
On Error Resume Next
With cnnmain
.CursorLocation = adUseServe
.ConnectionTimeout = 30
.CommandTimeout = 30
.Open "Provider=SQLOLEDB.1;Password=" & strPwd & ";Persist Security Info=True;User ID=" & strUser & ";Initial Catalog=" & strDataBase & ";Data Source=" & strServerIP
End With
If Err Then
Err.Clear
On Error GoTo myErr
Err.Raise "-1004", "", "DataBase Connect Error"
End If
rsCard.Open "select top 1 CardStatus from madmcard where cardno = '" & strCardNo & "'", cnnmain, adOpenKeyset, adLockReadOnly
If Err Then
Err.Clear
On Error GoTo myErr
Err.Raise "-1005", "", "SQL Run Error"
End If
If Not rsCard.EOF Then
Select Case rsCard.Fields("CardStatus") & ""
Case "正常":
GetCardState = 1
Case "挂失":
GetCardState = 2
Case "待发":
GetCardState = 3
Case "回收":
GetCardState = 4
Case "有卡销户":
GetCardState = 5
Case "挂失销户":
GetCardState = 6
Case Else: '其他卡状态
GetCardState = 999
End Select
Else
Err.Clear
On Error GoTo myErr
Err.Raise "-1006", "", "Can not Find the Card State"
End If
rsCard.Close
Set rsCard = Nothing
Set cnnmain = Nothing
Exit Function
myErr:
GetCardState = Err.Number
ErrStr = Err.Description
Set rsCard = Nothing
Set cnnmain = Nothing
End Function
=================
vb做的dll不是真正的dll,是active x。所以不能像vc,delphi做的dll那样被调用.
不然我也不会从vb版跑来vc版发贴了.
即使写的DLL能在我的数据库上调试成功,但如何保证在你的数据库也调用成功呢。只好UP一下。
这100分不能白送。
出来说两句吧。