Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




How To Connect To Sql Server By Connection String?


how to connect to a sql server by using connection string so that i can retrieve the data?
are they any related threads in this forum?
thanx.




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Trying To Connect To Server. Is My Connection String Incorrect ** Resolved **
When I was developing my application to connect to the database (just for checking) I used the following connection string

conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
                            "Persist Security Info=False;" & _
                            "Data Source = C:Documents and SettingsDefaultDesktopVB2forcheckinAssetDB.mdb"
    
and this worked. However now I when I install the app I want to connect to a server. The only code I changed was to the connection string and I get the error {Could Not Find the File "\ServerNameLocationAssetDB.mdb"}

the code I have for connection string is as follows

conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
                            "Persist Security Info=False;" & _
                            "Data Source = \ServerNameLocationAssetDB.mdb"

If anyone can tell me where I am going wrong I would be forever greatfull. HAHA. All tips will be appreciated. Thanks
    






Edited by - Shandy on 1/24/2004 3:42:02 AM

How To Connect Data Control To SQL Server Thro' Connection String
Hi

I am using Data control and I want to connect to SQL Server thro' Connection string(DSN less). Anybody could help me.

many thanks in advance.


vani

HOW TO CONNECT SERVER THROUGH DIAL UP CONNECTION
HI,

MY NAME IS CHANDU. Ple. solve my problem. we r develop projects in visual basic. we storing data in client systems(database mdb). and every day synchronising data to server. it is remote host. how to transfer(mdb tables) data from client to server. (Oracle data base are using in server.)

it is urgent . ple. how to solve this problem using visual basic 6.0.

thank you
Chandu.

Can We Safely Connect To A SQL Server On The Web Through A System ODBC Connection ?
Dear Friends,

I have a package which connects to the database through a system ODBC connection on a local network. Is it safe enough to move the database (SQL Server database) on to the web and continue using the package just like using on the local network ?

Thank You.

How To Disable Connection Pooling From SQL SERVER, Not Thru Connection String
my friend has getting "SQL Server Does Not Exist or Access Denied" and it is related to TCP-IP , now i want to simulate that error on my m/c so i need to off the connection pooling.
Plz advise for disabling connection pooling (not thru connection string)

SQL Server 2000 Connect String And DSN Problems
I have just installed SQL Server 2000 on a test PC and I'm trying to connect to it using a Connect String first, and then when that didn't work I tried a DSN. I'm using ADO in my VB project and my connect string looks like this:

ConnectString=Driver={SQL Server};Server=TEST;Database=Agribook;Driver=C:WINNTSystem32sqlsrv32.dll;LastUser=sa

I have taken/confirmed all the appropriate values from the registery. When I run the program I get an error stating:

ADO ERROR#: -2147467259
NATIVE ERROR#: 0
DESCRIPTION: [Microsoft][ODBC Driver Manager] Data source name not found
                and no default driver specified
SOURCE: Microsoft OLE DB Provider for ODBC Drivers
SQLSTATE: IM002


After playing with that for about 2 hours I gave up and just tried to use a DSN. That didn't work either. I keep getting this error:

ADO ERROR#: -2147217843
NATIVE ERROR#: 18452
DESCRIPTION: [Microsoft][ODBC SQL Server Driver][SQL Server]Login failed
                for user '(null)'. Reason: Not associated with a trusted SQL
                Server connection.
SOURCE: Microsoft OLE DB Provider for ODBC Drivers
SQLSTATE: 28000

I'm pretty stumped? My setup is simple, I have 2 PC's networked using File and Printer sharing. When I created my DSN I selected SQL Server Authentication and then entered the corresponding default userid 'sa'. Everything else is pretty standard. Anyone have any suggestions?

Thanks in advance.

Connection String To MS SQL Server
I'd like to connect to a MS SQL server 2000 in web, can someone tell me how the connection string is like? & how to create a recordset as well, thanks

Connection String Of SQL Server And Vb
any one can send me connection string of SQL server and vb

SQL Server - Connection String
In my VB app, how do i connect to SQL server using the current users's domain log in permissions?

(no local user / passwords)

Set Conn = Server.CreateObject("ADODB.Connection")
Set RS = Server.CreateObject("ADODB.Recordset")

Conn.Open "Driver={SQL Server};Server=127.0.0.1;Database=dbname;Uid=user;Pwd=password;"

Connection String For SQL Server
can anyone out there show me a sample of a connection string to a sql server...The stuff I have seen I cant make work.

Thanks

DVannoy
A+,Network+,CNA
dvannoy@onyxes.com


Connection String For Sql Server
hi,

i want to know the connection string that i can write in my VB module to connect to the database created in sql server 2000.
at present i have created a DSN which actually i'm not interested in creating b'cos i'll have to create it on client machine.
pls help me.

Sql Server Express Connection String
hello i am new user to sql express edition i ve been using sql server enterprise edition but now i want to convert my database in sql server express edition.

when i was using enterprise edition i just used the following sting which was succefull on both server and client .
Provider=SQLOLEDB.1;Persist Security Info=true;User ID=SA;pwd=PASS ;Initial Catalog=ACT_DATA; Data Source=SERVER


but now after convertig my databae to sql server express edition i ve used the following string

Provider=SQLOLEDB.1;Persist Security Info=true;User ID=SA;pwd=PASS ;Initial Catalog=ACT_DATA; Data Source=SERVERsqlexpress

this string works fine on the server but it doesnt work on cleints

i ve turned on the tcp ip protocol in sql server instance.

but no use

i also cant make odbc at cleint side

Understanding SQL Server Connection String
I have this connection string I found on this site. I don't understand it

Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=TVAMDiscrette;Data Source=SOEMKLTIMMFONG

I was going to try to build a connection string by using the Data Link Properties dialog but i was not successful so now i have to cut and paste. But i don't know what to change.

Thanks!

From Access To SQL Server. Will Changing The Connection String Do?
In working/School enviroment, we uses SQL server.

But at home, I uses MS Acess.

Usually I would just change the connection string to when i move the codes from one side to another.

Will there be any potential problems?

Thanks.

SQL Server Database Encryption. VB6 Connection String.
I want to know whether SQL Server 2000 has any facility of password protecting and encrypting database. How it can be coded with VB and how to set the connection string with these?

Connection String For SQL Server Instance Names
I have an SQL server on my local machine called:
IWDSWKS150IWDSWKS150.
I have 2 databases: IJ_WDSTK_PRODUCTION and IJ_WDSTK_PROD_DATA_MART.
Most of my data is selected from IJ_WDSTK_PRODUCTION but sometimes I have to get some data from IJ_WDSTK_PROD_DATA_MART. When I do this I use this string:

Code:
SELECT ID, destination as description
FROM IWDSWKS150IWDSWKS150.IJ_WDSTK_PROD_DATA_MART.dbo.Product_Destination ORDER BY description
but I keep getting the error message: Line 2: Incorrect syntax near ''
When I execute select @@servername in query analyser, I get the result:IWDSWKS150IWDSWKS150.
How can I get the query string to work?

SQL SERVER 2000 Connection String Problem
Does any one know why this connection string to SQL SERVER 2000 from a VB 6.0 App might now work.  I'm getting "Logon failed for UserXXX" and I know the credentials I'm supplying are correct:

Const ConnectStr = "Provider=SQLOLEDB.1;Data Source=SUPERMINE_SQL;Initial Catalog=Collections;User ID=MyUserName;Password=@v@aaq0rs2;Packet Size=4096"

How To Specify MS -SQL Server Port Number In Connection String
Hi,
I am trying to establish a connection with MS SQL server database. To do this I form a Connection String. In the connection String I specify the Database server name, User name and Password. Till this it is fine.
But my problem is I also want to specify the port number. by default it is 1433 for SQL Server, but what if SQL Server is running on some other port number. Then how do I specify this port number in Connection String?

Thanks,
Dipesh

How To Place The Connection String When The Database Is In Server For The Client !
Hai All,

  My database is MsAccess and developing the project in VB 6, If I am placing the database in the Server then how the Client will get the database connected through OLEDB, what will be the connection string. Here I need to give the server name also how I will specify it.

Thank you,
Chock.

Does Anyone Have Working SQL Server Express 2005 Connection String Examples
Hey,

I need to connect to SQL Server Express 2005 and it is driving me crazy right now.

Got Connection Strings????

How To Specify Database Server Or Connection String In A Crystal Report Object
Hi,
In Visual Basic how can I specify the
database server (or connectionstring)
of a crystal report object at runtime?

I need this because the .exe applications
in terminal computers are trying
to load a crystal report which
database resides in server "(local)"
(obviously because I designed the
report in the server and compiled
the visual basic .exe there too)

Thanks a lot for your help
Roland

How To Start Sql 2000 Server On Server Machine And Connect To Its Clients Via VB 6.0
how to start sql 2000 server on server machine and connect to its clients via VB 6.0 ...?

Having Trouble Programatically Setting Up The Connection String For OLE Connection
I am using VB to retrive a string I have in an access database. With the following code:

(myDB is declared publicly elsewhere... Public myDB As New ADODB.Connection)
Code:
Dim sPath As String
Dim myRS As New ADODB.Recordset
Dim sQuery as String

sPath = Environ("PeMMP_DB") & "ProvData"
myDB.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & sPath & "PeMMP_DB.mdb;Password='pemmpadmin';Persist Security Info=False"
myRS.Open "SELECT Queries.Query_Text FROM [Queries] WHERE (((Queries.Query_Num)=" & sQNum & "));", myDB 'Model_Num value must be changed manually
sQuery = myRS.fields.Item(0).Value

I have it working when I take the variables out of the path, but I need to allow the program to pass variables in. Any help or suggestions are greatly app.

Also I am writing this in a VBA envronment but need to port it to VB6 when ready. Are there any issues with database connections and recordsets I need to be aware of?

Thanks very much.
Craig



Edited by - DaVBMan on 6/26/2006 12:42:30 PM

Connection String Not Accepting The UserId When Opening Connection With Sql.
Hi,
I tried opening a database connection with sql
using the following code :

Dim lstrDbServer: lstrDbServer = "CD3CD3"
Dim lstrUserId: lstrUserId = "Administrator"
Dim lstrPassword: lstrPassword = "system"
Dim lstrDBName: lstrDBName = "Pubs"
Dim ConString
Dim connPubs

ConString = "Provider=MSDataShape;DATA PROVIDER=SQLOLEDB;Data Source=" & lstrDbServer & ";User Id=" & lstrUserId & ";Password=" & lstrPassword & ";Database=" & lstrDBName & ";Connect Timeout=10"

set connPubs = Server.CreateObject("ADODB.Connection")

connPubs.Open ConString

I got the following error :

Error Type:
Microsoft OLE DB Provider for SQL Server (0x80004005)
Login failed for user 'Administrator'. Reason: Not associated with a trusted SQL Server connection.

Why am i getting this error.
When i installed sql Server 2000 i set the sql server username as Administrator & Password as system.
Is there some way i can find out the username & password that i had entered while installing, just to check the spelling.

Do get back to me.

Toral

MySQL Connect - Cant Open Connection?
I am connecting to a MySQL DB. It connects ok, but when i run this code:


VB Code:
Private Sub cmdLogin_Click()    Dim recordCount As Double    'On Local Error GoTo Handle    Set objRecordset = New ADODB.Recordset    With objRecordset        .CursorLocation = adUseServer        .Source = "SELECT * FROM `users` WHERE username='" & txtUsername & "' LIMIT 1"        .ActiveConnection = objConnection        .Open    End With        While Not objRecordset.EOF = True        If objRecordset(1) = txtUsername Then            If objRecordset(2) = txtPassword.Text Then                LoggedIn = True                LoggedIn_User = txtUsername                Me.Hide                MsgBox "Good"                'POS.show            Else                MsgBox "The password you entered is incorrect. Please try again.", vbOKOnly + vbExclamation, "Login Error"                txtUsername.Text = ""                txtPassword.Text = ""            End If        Else            MsgBox "The username you entered was not found in the database. Please try again.", vbOKOnly + vbExclamation, "Login Error"            txtUsername.Text = ""            txtPassword.Text = ""        End If        recordCount = recordCount + 1        objRecordset.MoveNext    Wend        If recordCount = 0 Then        MsgBox "The username you entered was not found in the database", vbExclamation + vbOKOnly, "Login Error"    End If'Exit Sub'Handle:'        MsgBox Err.Description, vbCritical + vbOKOnly + vbSystemModal, "Error"'        Err.ClearEnd Sub


i get this error:

Code:
The connection cannot be used to preform this operation. It is either closed or invalid in this context


on this line:


VB Code:
With objRecordset        .CursorLocation = adUseServer        .Source = "SELECT * FROM `users` WHERE username='" & txtUsername & "' LIMIT 1"        .ActiveConnection = objConnection        [hl].Open [/hl]    End With

How To Connect Vbasic To Ms Access Using Ado Connection
hi guys....
im a new member here..
i need your help...
how will i connect vbasic to ms access using ado connection..
can you give atleast one examples..
im an IT student and i need this in my thesis..
thank you...
your reply is highly appreciated..

How To Connect My Application With The Internet Connection
hi all,

please help me regarding internet connection... because i dont know how to connect my application :

for example i have a database from this site http:\www.mysite.com
and the filename of databse is quiz.mdb
and i want to connect on the database but i cant.... lease help me please!!!

in local i used this code
dim Cnn as new adodb.connection

sub main()
with Cnn
.provider="Microsoft.Jet.OLEDB.4.0"
.open "path of my database"
end with
end sub

but i want is to connect trough the internet.....

please give me suggestion or code for this problem...
any suggestion or piece of code will be appreciated...

thank u very much...
joseph

Connect To MSDE, Trusted SQL Sever Connection?
Hi there.

This is newbie territory for me and I was wondering If I could get some really basic beginner help.

I've had MSDE installed for a while now and I would like to connect to it

I've tried using a connection with a username and password and keep getting errors. (Both from MSDE Admin and VB)

I wish I knew what all this means

Is there a "Create a MSDE database or Connect to a MSDE database for dummies" reference somewhere?

This doesn't help
http://www.msde.biz/msdeadmin/help/Help.htm

Looked here too.
http://www.able-consulting.com./MDAC...erForSQLServer

This got me closer (it actually connected... I think) but not with username/password.
http://www.xtremevbtalk.com/showthre...threadid=71581

Am I just being really thick headed?

BTW I posted the MSDE Admin link because I went ahead and bought the product from www.MSDE.biz

Thanks for looking

Max.

How To Check For Internet Connect - Cable Connection
I'm having trouble determining if a internet connection is present when I'm on Cable internet. My program checks for an internet connection and use to work great when I was on dial-up, but now I'm on cable and my MsgBox comes up saying you must be connected to the internet.

Help!

Thanks

Nascar8MDJ

Connect To A Progress Database Using An ODBC Connection Using VB 6
Hi,

I would like to connect to a progress 9.1c database using a ODBC connection using a merant driver via VB6.

Can somebody please assist in my ever growing problem

Error 8447 Internet Server Error When Trying To Connect To Access DSN On My Server
I'm trying to connect my vb6 application to a Access database located on my server...

I created a system DSN on my server for my Access db

I used the following code and it gives me an error ( '8447' Internet Server Error ), it is also the same error it gave me when I tried to use the code at the following post... http://www.vbcity.com/forums/topic.asp?tid=12903&highlight=access%7Cweb%7Cvb


code :

Private Sub Command1_Click()
Dim rsGeneric As ADODB.Recordset
Dim cnnGeneric As ADODB.Connection
'
Set cnnGeneric = New ADODB.Connection
'
cnnGeneric.Open "Provider=MS Remote;" _
    & "Remote Provider=MSDataShape;" _
    & "Remote Server=http://199.199.199.99;" _
    & "Data Source=Alert;" _
    & "User Id=test;Password=test;"
'
Set rsGeneric = New ADODB.Recordset
'
With rsGeneric
    .CursorLocation = adUseClient
    .Open "SELECT * FROM Livratemps", cnnGeneric
    .ActiveConnection = Nothing
End With

End Sub


the bold line is where the error is generated...


I think it's because I don't have my RDS set up...
Well, I don't know what is RDS...
Can somebody tell me what I have to do to activate RDS and get this code working...
Thanks a lot!!





Edited by - acad on 7/11/2003 7:49:49 AM

Connection To Database Sql Server In Server Failed
i use crystal report 8.5(crviewer to create report) in visual basic 6 and database using sql server . i use ODBC to connect to a database sql server in server and i want to use stored procedure in database sql server to make report.
my problem is connection failed and message box ' connection has not yet been open'.
why? help me

OPC Server Connect
I'm using an OPC Server to communication with a PLC and I'm having a little problem the very first time the program runs after a reboot of the system. It takes a little while for the OPC Server to connect therefore if I try to do anything beforehand, the program shuts down with the following error:


Quote:




PCU.exe has generated errors and will be closed by Windows. You will need to restart the program.

An error log is being created.




i've also tried using delays, but they dont seem to work right for me in this case.

I have put in commands for picking up errors before, but I can't seem to trap this one....is there some special way to watch for the above error?

oh yeah, i can't seem to find the error log

Thanks a million for any info


Nick

Connect To An Irc Server...
i im trying to make an ocx that connects to servers.

i used winsock and tried to connect it to irc.Qeast.net
well...

i've tried the command
winsock.Connect "irc.Qeast.net", 6667
but it doesnt work
can winsock connect to a server by the name? or it needs the ip?

and

that is some special info that i can send to irc so he can accept my connection ?

txs

Connect To Msn Server
How can i connect to the msn server ( messenger.hotmail.com:1863 )
I want to make my own messenger wich loads the people i have in my list into my own app.

Connect To MDB On Web Server - VB6
Scenario...

I had to create a program using VB, which is used to alter information in a Microsoft Access Database and also create a website, which is used to present the information in the database.

I've done this, but the method I've used involves the database being stored within the same location as where the program is running from or in a sub folder within the same directory as where the program is running from and the website requires the database be stored on the web server, in which it's being hosted from, so the only option I have is to alter the connection string to point to the database hosted on the web server, although sadly it doesn't seem to be as simple as that.


Background Info...

Web Server...
Windows XP Pro
Password Login
Running IIS
Scripts have been allowed on the directory in which the website and database is being hosted from.
Read and Write Access has been allowed for Web Users.
The directory is also shared for other Network users.

The database isn't password protected.

The closest I've got is connecting to the Database via another PC on the network and have had successful results, with the changes immediately taking effect on the website.

I've read somewhere that it used to be possible, but the functionality has now been taken away, due to the method being so in-secure, but why take the functionality away, when they could have simply informed of the security issues and allowed people to decide if they wish to take the risk.

Can anyone inform me otherwise?


Cheers!

Kirk

Connect To Db On Ftp Server
I know how to connect to my database when on my hard drive.

I just uploaded it to an ftp server...is there a way to connect to it?

SOmething like:

Set dbdist = DBEngine.OpenDatabase("ftp://mydatabase.location")?

Can someone help me out?

david

Connect To A SQL-Server Via DNS
Hi guys!

I hope this wasnt already a problem here, but it is a little difficult to perform a search with "dns" (4 letters are minimum)

Well, i can connect to any sql-server and its database with a non-dns-code:


Code:
Private Sub Form_Load()

Dim adoConn As New adodb.Connection
Dim adoRS As New adodb.Recordset
Dim sqlString As String

' The connection string
adoConn.ConnectionString = "Driver={SQL Server}; " & _
"Server=SQLSrv; " & _
"Database=MyDataBase; " & _
"UID=admin; " & _
"PWD=admin"

' The sql statement
sqlString = "SELECT dbdatetime FROM dwsys"

On Error Resume Next
'Open the whole thing
adoConn.Open

adoRS.Open sqlString, adoConn, adOpenKeyset, adLockPessimistic, adCmdText

' Do something here ...

adoRS.Close ' ... and disconnect again
adoConn.Close

Set adoRS = Nothing
Set adoConn = Nothing
End Sub
How can i connect to the same server via DNS??

Greets and thanks in advance!
Ben

Not Connect To SQL Server(DSN/DSN Less)
I have installed SQL 2000 just now. when i am connection to SQL
server using DSN or DSN Less to VB or ASP the following error is occuring and its not
connecting to SQL Server.
-------
Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E4D)
[Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user 'DS3IUSR_DS3'.
-------
I have check the login name and password its OK. but it steel shwos the
same error.


Help me Please.


Regard
Jam

Can't Connect To SQL Server!
Hi,

I'm developing an application with VB 6 & SQL Server 7.0. My problem occurs when the application is running on a client machine.

I setup the ODBC connection and run my application. TCP/IP is used in Network Library to connect to SQL Server. When I try to connect to the DB thru the application, an error message prompt:

[Microsoft][ODBC SQL Server Driver][Named Pipes]Specified SQL server not found.

While in another machine, where SQL Server client is installed, does not have this problem. Both workstations are running Win 2K prof SP3.

Does anyone have this experience and can help me??

Thanks!

How To Connect To SQL Server
i finished building up a forum with vBulltin Board
Howerver..I want to connect it to a database which i had restored?
How can I do that/
thanks

Connect To SQL Server?
i wanted to know if i can connect to a SQL sevrer and and use that as ur database with ADO or whatever. cause i have a webserver that has SQL, and i wnated to know if i can use that?

THANKS

Connect To SQL Server Through VB
Hi there,
I have been trying to connect to my sql 7 server for a while now, no luck. Im just starting out, but this is what I have so far, and I can't seem to pull anything up.. The Server is behind a firewall so don't mind the generic password.

My eventual goal is to make small programs that run one query at the click of a button, this is for employee useage really. I just wanted a small form to allow the entry of a ID then click the button, and run the query/update on the ID the employee entered. But I can't get a simple query to return anything yet. Any takers?

-Kaotik

Private Sub Command1_Click()
Dim query As String
query = "SELECT * FROM QUESTIONS"
Text1.Text = "query"
End Sub

Private Sub Form_Load()

Dim GEXCONN As String

GEXCONN = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=bb50;Data Source=0.0.0.0"

End Sub

How To Connect To SQL Server?
I don't know anything about SQL Server. Please help me.

I am writing a program to pull data from tables in SQL server and dump into MS Access database.

How to connect to SQL Server using VB6 codes?
How to query the records out so I can save to Access db?
Thanks,
Pal.

Connect VB With SQL Server !!
hi for every one
i have SQL Server database and i want to connect with visual basic forms
because i want to query about specific data from some tables
and i want to use the forms to do that


1- how can i connect vb with SQL Server?
2- how can i show records for some tables?
for exampl:
i use Data component when i connecting with access and i can see any records from any table in database .
what componenet can i use with SQL Server

thank you .

Connect To MSN Server :D
Hi all,
Does anyone know how to connect to the MSN server via Sockets(I think thats what it is called) via VB6?

I have downloaded some examples from pscode.com and they dont work
Regards
Cameron

Connect To Server
i am having an client-server application.
some of my text files are on server.
and exe running on client machine has to access that files on server.
now the problem is that , server has password and i do not want to leak a server passwrod to my users.
but for my application, user must access server and give its password as i mapped server's folder to user's local machine.
i want to find vb-code such that i will give password by my coding only,
no user will require to enter password of server to access server.
pls if anyone knows tell me solution.

Connect To Ms SQL Server DB !
any wizard help to connect to the database in vb6? vb .net does hav wizard help in connecting to database. feels strange suddenly go backward.

Copyright 2005-08 www.BigResource.com, All rights reserved