G
guy
Hello All,
I'm have a VB function that connect to SQL SERVER , get's information
and returns the relavant string.
using this function within VB application (say cmdbutton) works great,
but when trying to activate the function from asp page, i'm getting
nothing.
can anyone help here ?
here is the VB CODE :
=============================================================================
Option Explicit
Private Conn As ADODB.Connection
Private rs As ADODB.Recordset
Private Function connectDB() As Boolean
Dim ConnectionString As String
ConnectionString = "Provider=SQLOLEDB.1;" _
& "Integrated Security=SSPI;" _
& "Persist Security Info=False;" _
& "Initial Catalog=DBName;" _
& "Data Source=SERVER"
On Error GoTo errhandler
Set Conn = New ADODB.Connection
Conn.ConnectionTimeout = 5
Conn.ConnectionString = ConnectionString
Conn.Open
If Conn.State = adStateOpen Then
connectDB = True
Else
connectDB = False
End If
Exit Function
errhandler:
MsgBox "The Following Error accured:" & vbCrLf & _
Err.Description & vbCrLf & _
"Error Number:" & _
Err.Number, vbMsgBoxRight + vbMsgBoxRtlReading + vbCritical
End Function
Private Sub closeDB()
On Error GoTo errhandler
Conn.Close
Exit Sub
errhandler:
MsgBox "The Following Error accured:" & vbCrLf & _
Err.Description & vbCrLf & _
"Error Number:" & _
Err.Number, vbMsgBoxRight + vbMsgBoxRtlReading + vbCritical
End Sub
Public Function getSomthing(id As String) As String
Dim getID As String
If connectDB Then
Set rs = Conn.Execute("SELECT PName FROM PTable"
& "WHERE PID LIKE '" & id & "'")
Do While Not rs.EOF
getID = rs.Fields("PName")
rs.MoveNext
Loop
closeDB
Else
getID = "ooops ... connection to the server didn't succedded"
End If
getSonsOf = getID
End Function
==============================================================================
calling the function getSomthing from VB code returns the right
result,
but when compiling the code to .dll - the call to the function fails
!!
here is the ASP Code :
<%
set obj = Server.CreateObject("DBManagerProject.DBManager")
Response.Write obj.getSonsOf (100)
%>
I'm have a VB function that connect to SQL SERVER , get's information
and returns the relavant string.
using this function within VB application (say cmdbutton) works great,
but when trying to activate the function from asp page, i'm getting
nothing.
can anyone help here ?
here is the VB CODE :
=============================================================================
Option Explicit
Private Conn As ADODB.Connection
Private rs As ADODB.Recordset
Private Function connectDB() As Boolean
Dim ConnectionString As String
ConnectionString = "Provider=SQLOLEDB.1;" _
& "Integrated Security=SSPI;" _
& "Persist Security Info=False;" _
& "Initial Catalog=DBName;" _
& "Data Source=SERVER"
On Error GoTo errhandler
Set Conn = New ADODB.Connection
Conn.ConnectionTimeout = 5
Conn.ConnectionString = ConnectionString
Conn.Open
If Conn.State = adStateOpen Then
connectDB = True
Else
connectDB = False
End If
Exit Function
errhandler:
MsgBox "The Following Error accured:" & vbCrLf & _
Err.Description & vbCrLf & _
"Error Number:" & _
Err.Number, vbMsgBoxRight + vbMsgBoxRtlReading + vbCritical
End Function
Private Sub closeDB()
On Error GoTo errhandler
Conn.Close
Exit Sub
errhandler:
MsgBox "The Following Error accured:" & vbCrLf & _
Err.Description & vbCrLf & _
"Error Number:" & _
Err.Number, vbMsgBoxRight + vbMsgBoxRtlReading + vbCritical
End Sub
Public Function getSomthing(id As String) As String
Dim getID As String
If connectDB Then
Set rs = Conn.Execute("SELECT PName FROM PTable"
& "WHERE PID LIKE '" & id & "'")
Do While Not rs.EOF
getID = rs.Fields("PName")
rs.MoveNext
Loop
closeDB
Else
getID = "ooops ... connection to the server didn't succedded"
End If
getSonsOf = getID
End Function
==============================================================================
calling the function getSomthing from VB code returns the right
result,
but when compiling the code to .dll - the call to the function fails
!!
here is the ASP Code :
<%
set obj = Server.CreateObject("DBManagerProject.DBManager")
Response.Write obj.getSonsOf (100)
%>