Solved

Connectig VB6 to SQL Server 2005 Express

Posted on 2009-05-12
3
469 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 41

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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Join & Write a Comment

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

708 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now