|
![]() |
名片设计 CorelDRAW Illustrator AuotoCAD Painter 其他软件 Photoshop Fireworks Flash |
|
VB- 工程 -引用 - ADO 2.0 ,建一个类DB,工程名设为 SQLCONN 以下是偶程序中的部分代码,大家有空可以试试 Option Explicit Public strError As String Public Conn As New ADODB.Connection Public Rs As New ADODB.Recordset Public Property Get ErrorString() As String ErrorString = strError End Property Public Function Conn_Open(strSQLServerName, strSQLDBUserName, strSQLDBPassword, strSQLDBName) Dim strCon As String Set Conn = New ADODB.Connection On Error GoTo errHandler: strCon = "Provider=SQLOLEDB;Server=" & strSQLServerName & ";User ID=" & strSQLDBUserName & ";Password=" & strSQLDBPassword & ";Database=" & strSQLDBName & ";" Conn.Open strCon errHandler: strError = "错误源:" & Err.Source & vbCrLf & "描述:" & Err.Description Exit Function End Function Function GetRootID(ByVal ClassID) Dim query query = "select class_ID,RootID from tblCategory where class_id=\\\'" & ClassID & "\\\'" Set Rs = Conn.Execute(query) If Not (Rs.EOF And Rs.BOF) Then GetRootID = Rs("RootID") Else GetRootID = ClassID End If Rs.Close Set Rs = Nothing End Function 编译后,在ASP中这样用 function GetRootID(byval id) \\\' 获取根类ID号 set S_DB = server.CreateObject( "SQLCONN.DB") S_DB.Conn_Open strSQLServerName,strSQLDBUserName,strSQLDBPassword,strSQLDBName GetRootID = S_DB.GetRootID(id) Set S_DB=nothing end function 返回类别: 教程 上一教程: SQL语法及ASP中SQL语句参考及记录集对象 下一教程: 在WEB.CONFIG中添加连接字符串 您可以阅读与"COM组件中如何连接数据库"相关的教程: · asp+中是如何连接数据库ado+的 · ASP连接数据库的全能代码 · ADO连接数据库字符串大全 · 将连接数据库的代码隐藏在DLL中 · 连接数据库查询手册 |
![]() ![]() |
快精灵印艺坊 版权所有 |
首页![]() ![]() ![]() ![]() ![]() ![]() ![]() |