Solved

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

Posted on 1998-07-10
9
258 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
 
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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

707 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now