Solved

Connectig VB6 to SQL Server 2005 Express

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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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 utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

738 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