|
 |
asp_database_setup thread: ASP and DSN Connection
Message #1 by KAMATHM@N... on Thu, 10 Oct 2002 14:46:10 -0400
|
|
I am working on a project which has ASP as the front-end and it accesses a
Visual Basic ActiveX DLL for the database connection. After the user is
authenticated on the ASP website, he is connected to the VB DLL with a
Server.CreateObject call. and then the method call. I am running into
problems with the ConnectionString parameter. I have created a System DSN
called "PricingReports". I created this connection with an Microsoft ODBC
for Oracle driver. I am not sure if I have OLEDB drivers as it does not
show up on the list of available drivers. I have a Windows NT 4.0 operating
system.
Following is the VB code:
Public Function RetrieveUser(ByVal strLoginName As String) As String
On Error GoTo ErrHandler
'Variable Declaration
Dim conn
Dim rsEmployeeID
Dim strUserID As String
Dim strUserName As String
'Create Connection to local database
Set conn = CreateObject("ADODB.Connection")
conn.Open "DSN=PricingReports;uid=kamathm"
'conn.Open
'set up record set
Set rsEmployeeID = CreateObject("ADODB.Recordset")
'open recordset - Enter in the required tablename/userid/username
fields
rsEmployeeID.Open "Select USER_CD,EMPL_FRST_NM FROM EMPL where USER_CD
= strLoginName", conn
'Get the value of the Id and Name fields into the variables
strUserID = rsEmployeeID.Fields("USER_CD").Value 'Enter in the correct
<userid> column name from the table
strUserName = rsEmployeeID.Fields("EMPL_FRST_NM").Value 'Enter the
correct column name
RetrieveUser = strUserName
'The ASP code would then issue the Response.Write commands to write out
the the strUserName variable.
'close the recordset and connection
rsEmployeeID.Close
conn.Close
Exit Function
ErrHandler:
Err.Raise Err.Number, Err.Source, Err.Description
End Function
Please let me know what I should do to get this code working.
Thanks
Meenal
Message #2 by Greg Griffiths <greg2@s...> on Thu, 10 Oct 2002 21:17:20 +0100
|
|
What if any errors do you get ?
At 14:46 10/10/02 -0400, you wrote:
>I am working on a project which has ASP as the front-end and it accesses a
>Visual Basic ActiveX DLL for the database connection. After the user is
>authenticated on the ASP website, he is connected to the VB DLL with a
>Server.CreateObject call. and then the method call. I am running into
>problems with the ConnectionString parameter. I have created a System DSN
>called "PricingReports". I created this connection with an Microsoft ODBC
>for Oracle driver. I am not sure if I have OLEDB drivers as it does not
>show up on the list of available drivers. I have a Windows NT 4.0 operating
>system.
>
>Following is the VB code:
>
>Public Function RetrieveUser(ByVal strLoginName As String) As String
> On Error GoTo ErrHandler
>
>'Variable Declaration
> Dim conn
> Dim rsEmployeeID
> Dim strUserID As String
> Dim strUserName As String
>
> 'Create Connection to local database
> Set conn = CreateObject("ADODB.Connection")
> conn.Open "DSN=PricingReports;uid=kamathm"
> 'conn.Open
>
> 'set up record set
> Set rsEmployeeID = CreateObject("ADODB.Recordset")
>
> 'open recordset - Enter in the required tablename/userid/username
>fields
> rsEmployeeID.Open "Select USER_CD,EMPL_FRST_NM FROM EMPL where USER_CD
>= strLoginName", conn
>
> 'Get the value of the Id and Name fields into the variables
> strUserID = rsEmployeeID.Fields("USER_CD").Value 'Enter in the correct
><userid> column name from the table
> strUserName = rsEmployeeID.Fields("EMPL_FRST_NM").Value 'Enter the
>correct column name
>
> RetrieveUser = strUserName
> 'The ASP code would then issue the Response.Write commands to write out
>the the strUserName variable.
>
> 'close the recordset and connection
> rsEmployeeID.Close
> conn.Close
>
> Exit Function
>ErrHandler:
> Err.Raise Err.Number, Err.Source, Err.Description
>
>
>End Function
>
>Please let me know what I should do to get this code working.
>
>Thanks
>Meenal
>
>
>
>%%email.unsub%%
>
|
|
 |