473,396 Members | 2,154 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Connecting to SQLServer in VB6 (using ADODB) works fine within VB appliction but not from ASP page

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)
%>
Jul 19 '05 #1
2 2411

"guy" <gu********@polycom.co.il> wrote in message
news:ae**************************@posting.google.c om...
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 :
================================================== ==========================
=
set Conn = Server.CreateObject(ADODB.Connection)
set rs = Server.CreateObject(ADODB.Recordset)

Function connectDB

Dim ConnectionString
ConnectionString = "Provider=SQLOLEDB.1;" _
& "Integrated Security=SSPI;" _
& "Persist Security Info=False;" _
& "Initial Catalog=DBName;" _
& "Data Source=SERVER"
Conn.ConnectionTimeout = 5
Conn.ConnectionString = ConnectionString

Conn.Open ConnectionString

If Conn.State = 1 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)
%>

Jul 19 '05 #2
This is because you are launching VB as *you* and you are authenticating
against SQL Server as *you.*

The ASP page is authenticating as IUSR_your_machine_name which very likely
isn't recognized by SQL Server. I suggest using SQL authentication unless
you are planning on disabling anonymous access, having all of your users
authenticate, and adding them to a group that has sufficient access to SQL
Server...

--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/


"guy" <gu********@polycom.co.il> wrote in message
news:ae**************************@posting.google.c om...
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)
%>

Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jessard | last post by:
Help! Hi, I'm having a bit (well a lot - it's getting annoying) of trouble using a C# class library within a VBScript on a computer other than the development machine. All the class is needed...
0
by: Asim | last post by:
I seem to be having a lot of problems with running/developing web site on my XP Professional OS. I have a simple web site (using ASP/VB), which retrieves information from an Access 2000...
1
by: Julie Barnet | last post by:
Hi, I am having a problem with my session state through sql server. This used to work, then all of a sudden (the only change was setting up replication in the sqlserver database) it stopped...
4
by: Thomas Scheiderich | last post by:
I get an error from trying to connect to my Sql6.5 server (which is why I am using Ole). It says the server doesn't exist or the password is wrong. I can't understand that because I use...
11
by: Patrick | last post by:
I have an ASP.NET application that connects to a SQL Server database. The SQL Server resides on a seperate development server from the IIS5.1 on Windows XP SP2 on development PCs which host the...
1
by: luis valencia | last post by:
I have an asp.net page that executes a DTS. When I execute that DTS from enterprise manager it takes about 5000 rows from the as400 and insert into sql server It works right. but when I execute it...
1
by: RLN | last post by:
RE: Access 2003 using WinXP SP2 Problem: When I start up my app I double click either one of my two Oracle tables in the table list, it asks for an id and pass. I need them to be linked at...
2
by: Jim Devenish | last post by:
I am in the early stages of converting a back-end .mdb file to SqlServer - my first attempt! I have used Data Transformation Services to copy all the tables to SqlServer into a database named...
0
by: jags_32 | last post by:
Hello We use MFG-PRO as our ERP system which in turn uses Progress databases. In the old version of SQL 2000, using DTS packages, we used to set the code page via command prompts and execute DTS...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.