Solved

URGENT!!! How do I connect to an SQL server via ODBC and VBScript??

Posted on 1998-07-10
9
297 Views
Last Modified: 2010-03-19
I need to connect to a SQL Server (version 6.5) via ODBC from an ASP application. How? All i get is "Invalid login" or "error: 'Undefined'".
Here is a part of the code, maybe It´ll help, though I don´t understand It...

dim login,result
login = SqlLogin
result = SqlSetLUser(login,"username")
result = sqlsetlpwd(login, "password")

As mentioned before this i VERY URGENT!!
0
Comment
Question by:Dempa
9 Comments
 
LVL 28

Accepted Solution

by:
sybe earned 200 total points
ID: 1091715
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "DSN=ODBC_NAME;SERVER:Server_Name;UID=User_ID;PWD=password;APP=;DATABASE=Database_Name"


0
 
LVL 28

Expert Comment

by:sybe
ID: 1091716
0
 

Author Comment

by:Dempa
ID: 1091717
Ok, but what is ODBC_NAME? I´ve tried A LOT of different things on that one but so far all i get is this message:

Microsoft OLE DB Provider for ODBC Drivers error '80004005'

[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

/Con.Net/minitab.asp, line 41

I don't know what to do...
0
Backup Solution for AWS

Read about how CloudBerry Backup fully integrates your backups with Amazon S3 and Amazon Glacier to provide military-grade encryption and dramatically cut storage costs on any platform.

 
LVL 28

Expert Comment

by:sybe
ID: 1091718
You will have to make an ODBC to the database.

Control Panel, ODBC32, System DSN, Add, SQL Server, Finish
Then

Give it a name (this the name you will have to use as ODBC_Name)
select the server.
Select the options you want to use. I prefer to use SQL Server authentication
(these things are also mentioned in the ASP statement: servername and user pass)

for the rest defaults are ok


0
 

Expert Comment

by:vinoopauls
ID: 1091719
Try this code:
    I dont think you have to configure the ODBC.

    Set con1 = New ADODb.Connection
    con1.Open ("driver={sql server};
                       server=SERVER NAME;
                       Database=DATABASE NAME;
                       PWD=PASSWORD;
                       UID=User_ID;")

0
 

Author Comment

by:Dempa
ID: 1091720
But I already have an ODBC connection set up on the machine that's running the IIS...do I have to set one up on my machine as well? (My machine is the one running the SQL server)
0
 
LVL 28

Expert Comment

by:sybe
ID: 1091721
No, you need only an ODBC on the machine that is running the server. It should point to the database on your machine

Conn.Open "DSN=ODBC_NAME;SERVER:Server_Name;UID=User_ID;PWD=password;APP=;DATABASE=Database_Name"

Server_Name should be your machine.

The error points clearly to the ODBC, so or your statement which makes the Conn-object contain an error, or the ODBC connection contains an error.

0
 

Expert Comment

by:clique10
ID: 1091722
Just TRY this, like Give a Blank UID=;PWD=; which will pop us the default SQL Login window which shows the DSN Name also then use the sa UID and PWD then If the system Logs in the DSN is OK Else the DSN maybe a Problem of having Different/Unknown Server.

(I EXPERIENCED THIS)
Rarely it may be a Chance of the Event Log Being Filled up OR
TEMPDB has been Choked Up
0
 

Author Comment

by:Dempa
ID: 1091723
Oops, sorry guys i forgot this one...Its working now. I finally got the tip from sybe working so he'll get the points..

Thanx for all your help, I really appriciate it!
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

When you hear the word proxy, you may become apprehensive. This article will help you to understand Proxy and when it is useful. Let's talk Proxy for SQL Server. (Not in terms of Internet access.) Typically, you'll run into this type of problem w…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question