Solved

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

Posted on 1998-07-10
9
303 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
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…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties

738 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