类型:转载 责任编辑:asp.net 日期:2007/05/23
热门软件下载:
因为小弟赶时间,来不及学vc了,现有一vb代码,要求用vc做成dll,要求vb,vc能调用。
现在请大家帮个忙把dll做好发给我。anson_ye@126.com。
重酬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,不然就帮你做拿分了!
我有时间,可是没水平呀!!:
UP
不懂vb,:(
还是自己动手吧,丰衣足食
你可以用vb做成dll,在vc,vb 中都可以调用,这样不是不用你学习vc了吗?
调试麻烦啊, 因为你的代码还调用了数据库。
即使写的DLL能在我的数据库上调试成功,但如何保证在你的数据库也调用成功呢。
只好UP一下。
vb不熟,呵呵