Solved

Connectig VB6 to SQL Server 2005 Express

Posted on 2009-05-12
3
482 Views
Last Modified: 2013-11-25
Hi
I am trying to connect my exisiting database ShinFlow.mdf to a MSHFlexGrid object in VB6 and am having some issues.  I have the included code at the moment but am getting error:

SQL Network Interfaces: Error locating Server/instance specified [xFFFFFFFF]

Any ideas what I'm doing wrong?   My experience in this area is very limited so any clues or ideas would be very helpful.

To preempt my next question does anyone have any links to some good resources on this area?  I shall after the connection is established want to view, sort, run queries, modify entries, add new entries etc.  and any pointers you have would be very much appreciated.  

Thanks in advance
Dim cn As ADODB.Connection
    Set cn = New Connection
    cn.ConnectionString = "Provider=SQLNCLI.1;Integrated Security=SSPI;" & _
        "Persist Security Info=False;" & _
        "AttachDBFileName=" & App.Path & "C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\ShinFlow.mdf;Data Source=server1\sqlexpress"
    cn.Open
    
    Dim rs As Recordset
    Set rs = New Recordset
    rs.Open "Select * from Job Table", cn
    Set MSHFlexGrid1.DataSource = rs

Open in new window

0
Comment
Question by:viralss
3 Comments
 
LVL 42

Expert Comment

by:pcelba
ID: 24370082
Your connection string does not look correct. Connection string examples are here:
http://www.connectionstrings.com/
0
 
LVL 1

Accepted Solution

by:
sidkud earned 500 total points
ID: 24375467
Your connection string is fine except for the app.path part. Do not append app.path to the mdf file path (unless the file is stored in a path relative to your application). But here are some probabilities for the actual error you are getting:
 
1) Make sure your server name is correct, e.g., no typo on the name.
2) Make sure your instance name is correct and there is actually such an instance on your target machine. Some application converts \\ to \. If you are not sure about your application, please try both Server\Instance and Server\\Instance in your connection string
3) Make sure the server machine is reachable
4) Make sure SQL Browser service is running on the server.

source: http://blogs.msdn.com/sql_protocols/archive/2007/05/13/sql-network-interfaces-error-26-error-locating-server-instance-specified.aspx 


0
 
LVL 4

Expert Comment

by:coolcurrent4u
ID: 34833196
0

Featured Post

Technology Partners: 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!

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

762 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