Link to home
Start Free TrialLog in
Avatar of JDL129
JDL129

asked on

Connection string from vb6 to sqlServer 2005 express

I need a connection string from vb6 to sqlserver 2005 express:
CAKPOSSERVER\SQLEXPRESS,
Database = "Barcode"
User = "POSiTrack"
PWD = "Fire4635"

Please no links!!

Thanks,
Jerry
Avatar of Rajkumar Gs
Rajkumar Gs
Flag of India image

Try this connectionstring

Provider=SQLOLEDB.1;Data Source =CAKPOSSERVER\SQLEXPRESS;Initial Catalog=Barcode;User ID=POSiTrack;Password=Fire4635;

Raj
Avatar of JDL129
JDL129

ASKER

RajkumarGS!!!!

How would I use this?

Thanks,
Jerry
check here

http://msdn.microsoft.com/en-us/library/bb264566(SQL.90).aspx

Dim cn As ADODB.Connection
Set cn = New Connection
cn.ConnectionString = "Provider=SQLNCLI.1;Integrated Security=SSPI;" & _
        "Persist Security Info=False;" & _
        "AttachDBFileName=" & App.Path & "\northwnd.mdf;Data Source=server1\sqlexpress"
cn.Open
also try this

adoConn.Open "PROVIDER=MSDataShape;Data Provider=SQLNCLI.1;Persist Security Info=0;User ID=UserName;Password=Password;Initial Catalog=DatabaseName;Data Source=servername"
Avatar of JDL129

ASKER

HainKurt!!!!

I've tried both of these and I keep getting "Object or with block not set"

Dim db As ADODB.Connection
db.ConnectionString = "Provider=SQLNCLI.1;Integrated Security=SSPI;" & _
        "Persist Security Info=False;" & _
        "AttachDBFileName=CAKPOSSERVER\C\PROGRAM FILES\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\BARCODE.MDF;Data Source=CAKPOSSERVER\sqlexpress"
db.Open

db.Open "PROVIDER=MSDataShape;Data Provider=SQLNCLI.1;Persist Security Info=0;User ID=POSiTrack;Password=Fire4635;Initial Catalog=Barcode;Data Source=CAKPOSSERVER\SQLEXPRESS"

What am I missing?
Thanks!!!!
Jerry
you are missing this

Set cn = New ADODB.Connection
check 28303147 to see how it is defined, set and used...
Avatar of JDL129

ASKER

HainKurt!!

Dim db As ADODB.Connection
Dim rs As ADODB.Recordset
Set db = New ADODB.Connection

db.Open "PROVIDER=MSDataShape;Data Provider=SQLNCLI.1;Persist Security Info=0;User ID=POSiTrack;Password=Fire4635;Initial Catalog=Barcode;Data Source=CAKPOSSERVER\SQLEXPRESS"

It appears that the database opens but the error I get now is "Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another"  Origianlly this was connected to an Access database and I'd like to connect to the sql server in a way the opening a recordset in sqlserver is not much different from opening it in Access if that's possible.

Set rs = db.OpenRecordset("tblCompany", dbOpenSnapshot)
If rs!INTERFACE = "NONE" Then
    gblnInterface = False
ElseIf rs!INTERFACE = "PSI" Then
    gblnInterface = True
End If

Thanks for your help!!!!
Jerry
on which line do you get thuis error?
check here

http://www.w3schools.com/ado/met_rs_open.asp

Set rs = db.OpenRecordset("tblCompany", dbOpenSnapshot)
-->
Set rs = db.OpenRecordset ("tblCompany")
also change these lines

If rs!INTERFACE = "NONE" Then
    gblnInterface = False
ElseIf rs!INTERFACE = "PSI" Then
    gblnInterface = True
End If

-->
if not rs.EOF Then
  gblnInterface = ( rs("INTERFACE") = "PSI" )
End if
ASKER CERTIFIED SOLUTION
Avatar of HainKurt
HainKurt
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of JDL129

ASKER

Great job!!  Thanks for your help