?
Solved

Connectig VB6 to SQL Server 2005 Express

Posted on 2009-05-12
3
Medium Priority
?
499 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 43

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 2000 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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…

850 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