Solved

Connectig VB6 to SQL Server 2005 Express

Posted on 2009-05-12
3
490 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: 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

In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
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 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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

691 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