|
When I try to make a connection to the db from VB I get this error message.
"A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)"
I'm am using the default named instance.
The connection works just fine with the SQL Server Management Studio and the configuration manager. I've done two days of searching and trying various items that I've found but nothing seems to work.
Any help would be most appreciated.
|
|
|
|
|
Any chance we can see your connection string?
|
|
|
|
|
Thanks Elliot,
This is the connection string from the machine.config file in the C:\WINDOWS\Microsoft.net\framework\v2.0.50727\CONFIG file.
<add name="LocalSqlServer" connectionstring="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|GGTEST.mdf;User Instance=true" providername="System.Data.SqlClient">;
Garth
|
|
|
|
|
|
The link you sent wrote: Server Error in '/' Application.
The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
Requested URL: /article.aspx
Version Information: Microsoft .NET Framework Version:2.0.50727.3074; ASP.NET Version:2.0.50727.3074
|
|
|
|
|
Eliott,
Don't know why my posts are changing what I write.
Will you share your email address? I'll send it to you that way.
Thanks
Garth
|
|
|
|
|
Eliott,
I have a feeling that I'm looking for the connection string in the wrong place. Where would I find it? This is VB2008 Express - a windows desktop application (not web page).
Thanks
Garth
|
|
|
|
|
Garth Geoghan wrote: Verify that the instance name is correct and that SQL Server is configured to allow remote connections.
Is the server running on a seperate machine?? By default, SQL Server does not allow connections from other machines. You have to open up the Configuration Manager and enable this yourself.
|
|
|
|
|
Thanks Dave,
No, the server is on the same machine.
Garth
|
|
|
|
|
In that case, we'd need the connection string. Your other post was apparently full of XML tags, so the string never showed. Post just the connection string, not the enclosing XML tags.
|
|
|
|
|
Thanks Dave,
Please tell me where I would find the connection string that you need? Machine.config? Which one?
Garth
|
|
|
|
|
This is the connection string from the machine.config file in the C:\WINDOWS\Microsoft.net\framework\v2.0.50727\CONFIG file.
connectionstring = "data source=.\SQLEXPRESS; Integrated Security=SSPI;AttachDBFilename=|DataDirectory|GGTEST.mdf;User Instance=true" providerName="System.Data.SqlClient"
|
|
|
|
|
The connection string you posted is for an Express Edition of SQL Server, not for the Developer or normal editions.
First, is the GGTEST.mdf file in the same directory as the .EXE you launched? While debugging, this would be in the Debug or Release folders under the bin folder in your project folder.
|
|
|
|
|
Dave,
Thanks for hanging in there with me.
I may not be looking in the right place for the connection string.
The one I sent you I found in a machine.config file. I've been messing with it and regardless what I set the file name or server instance to, the sql server management studio and the sql server connection manager connect to my db just fine. That tells me that I'm looking in the wrong place for the connection string.
I just found a connection string by going into Microsoft Visual Studio IDE. The properties for the connect there show this as the connection string: "Data Source=LENOVO\;Initial Catalog=GGTest;Integrated Security=True". This makes more sense to me as my server name is LENOVA and it references the correct database name.
The GGTEST.mdf file is in c:\Program Files\Microsoft SQL Server\MSSQL.10.MSSQLSERVER\MSSQL\DATA which is where it was created, by default, from within SQL Server. The program exe is in ...My Documents\Visual Studio 2008\Projects\WindowsApplication1\Bin\debug and in the same path ending with release.
Garth
|
|
|
|
|
Correction.
The application path is:
...My Documents\Visual Studio 2008\Projects\WindowsApplication1\WindowsApplication1\Bin\debug
{see WindowsApplication1 twice in the path}
|
|
|
|
|
OK, then you're not using SQL Server Express, you're using a full version of SQL Server.
"Data Source=LENOVO\;Initial Catalog=GGTest;Integrated Security=True"
This string assumes that you have added your user account to SQL Servers users and have assigned the proper rights to get at your database. It also assumes that you really do want to use your Windows logon account as the account to login to SQL Server with.
The connection string you found would be better placed in your applications app.config file, not in the machine.config.
|
|
|
|
|
VB2008 did not create an app.config file for this project.
|
|
|
|
|
It never does. You have to add it yourself. You-click the project node in the Solution Explorer and click on Add...
|
|
|
|
|
Dave,
From Solution Explore (on the project node) when I add a local database it assumes that I want an SQL Server Compact 3.5 database. What I want to do is attach to a db created in SQL Server 2008 Developer. So when I reset to this as my preference I then get back to the same problem - this error message:
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
Note: When I accept the Compact 3.5 option, the db is created and I can interact with it successfully from the database explorer.
Question: Does VB2008 Express limit one to using just a Compact 3.5 database?
Thanks so much for your continuing help on this.
Garth
|
|
|
|
|
I got through to tech support at Microsoft. The conclusion was that I am using VB2008 Express. Apparently the Express edition limits the capabilities that you have to interact with SQL Server 2008 Developer edition.
|
|
|
|
|
Hi all,
I'm working on an application, in which the first step is to append all files in a folder selected through FolderDialogBox.
It works perfevtly.
There is a change in the requirement now.
The change is, all .txt files within the selected folder and .txt files in the subfolders of the selected folder has to be appended.
Any help on this requirement witll be helpful.
Is there any posibility to upload my code in text file format?
If so please let me know, so that I can upload the code.
Its not possible to paste the code here, cos it has more number of line.
Thanks in advance.
modified on Thursday, October 8, 2009 6:40 AM
|
|
|
|
|
Don't bother uploading all your code, chances are no one will audit it for you.
As for your requirements, I'd advise you to take a look at recursion for navigating through a hierarchy of folders, you can use a List or another type of Collection to keep track of .txts before calling some logic to append them all to a new file.
|
|
|
|
|
Can you suggest any article for recursion?
I searched but could'nt get a good one.
|
|
|
|
|
You can make use of GetDirectories method to get all the directories under the top folder and then do as needed. One of its overload takes in SearchOption as parameter, use that one.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
Thanks for your suggestion.
Will checkout.
|
|
|
|