My program has to access an SQL Server DB file that is in the same folder as
the executable. i dont want to setup a server. i was able to do this on my
own computer, the program would access any sql server db file without it
being attached to the server. When i take it to another system it fails to
run.
All systems have SQL Server Express and SQL Server 2005 installed.
Can someone please direct me through the steps to fix this problem?
There are 2 errors (on different pcs) i get when i try to access the db one
is:
Error 1
Generating user instances in SQL Server is disabled. Use sp_configure 'user
instances enabled' to generate user instances.
---------------------------
Error 2
---------------------------
System.Data.SqlClient.SqlException: An error has occurred while establishing
a connection to the server. When connecting to SQL Server 2005, this failure
may be caused by the fact that under the default settings SQL Server does not
allow remote connections. (provider: SQL Network Interfaces, error: 26 -
Error Locating Server/Instance Specified)
at System.Data.SqlClient.SqlInternalConnection.OnErro r(SqlException
exception, Boolean breakConnection)
at
System.Data.SqlClient.TdsParser.ThrowExceptionAndW arning(TdsParserStateObject
stateObj)
at System.Data.SqlClient.TdsParser.Connect(Boolean& useFailoverPartner,
Boolean& failoverDemandDone, String host, String failoverPartner, String
protocol, SqlInternalConnectionTds connHandler, Int64 timerExpire, Boolean
encrypt, Boolean trustServerCert, Boolean integratedSecurity, SqlConnection
owningObject, Boolean aliasLookup)
at
System.Data.SqlClient.SqlInternalConnectionTds.Ope nLoginEnlist(SqlConnection
owningObject, SqlConnectionString connectionOptions, String newPassword,
Boolean redirectedUserInstance)
at
System.Data.SqlClient.SqlInternalConnectionTds..ct or(DbConnectionPoolIdentity
identity, SqlConnectionString connectionOptions, Object providerInfo, String
newPassword, SqlConnection owningObject, Boolean redirectedUserInstance)
at
System.Data.SqlClient.SqlConnectionFactory.CreateC onnection(DbConnectionOptions
options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection
owningConnection)
at
System.Data.ProviderBase.DbConnectionFactory.Creat ePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options)
at System.Data.ProviderBase.DbConnectionPool.CreateOb ject(DbConnection
owningObject)
at
System.Data.ProviderBase.DbConnectionPool.UserCrea teRequest(DbConnection
owningObject)
at System.Data.ProviderBase.DbConnectionPool.GetConne ction(DbConnection
owningObject)
at
System.Data.ProviderBase.DbConnectionFactory.GetCo nnection(DbConnection
owningConnection)
at
System.Data.ProviderBase.DbConnectionClosed.OpenCo nnection(DbConnection
outerConnection, DbConnectionFactory connectionFactory)
at System.Data.SqlClient.SqlConnection.Open()
at DBManager.SqlDBManager.ConnectToDB() in C:\Documents and
Settings\Alessandro Del Piero\My Documents\Visual Studio
2005\Projects\DBManager\DBManager\SqlDBManager.cs: line 53
at DBModule.Form1.button2_Click(Object sender, EventArgs e) in
G:\DBModule\DBModule\Form1.cs:line 205
---------------------------
OK
--------------------------- 4 23715
On Sat, 11 Feb 2006 03:09:27 -0800, AlexDP
<Al****@discussions.microsoft.com> wrote:
[snip]
If you are using a provider (Internet) you will have to get the
provider to make the settings recommended in the second message.
If you are on a local network you will need to get the Network staff
to make the settings for you.
Otis Mukinfus http://www.otismukinfus.com http://www.tomchilders.com
Alex,
Check this link, it will tell you how to create a connection to SQL
Server and attach to a database file: http://msdn2.microsoft.com/en-us/library/ms165716.aspx
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"AlexDP" <Al****@discussions.microsoft.com> wrote in message
news:6B**********************************@microsof t.com... My program has to access an SQL Server DB file that is in the same folder as the executable. i dont want to setup a server. i was able to do this on my own computer, the program would access any sql server db file without it being attached to the server. When i take it to another system it fails to run. All systems have SQL Server Express and SQL Server 2005 installed.
Can someone please direct me through the steps to fix this problem?
There are 2 errors (on different pcs) i get when i try to access the db one is:
Error 1
Generating user instances in SQL Server is disabled. Use sp_configure 'user instances enabled' to generate user instances.
--------------------------- Error 2 --------------------------- System.Data.SqlClient.SqlException: An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
at System.Data.SqlClient.SqlInternalConnection.OnErro r(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndW arning(TdsParserStateObject stateObj)
at System.Data.SqlClient.TdsParser.Connect(Boolean& useFailoverPartner, Boolean& failoverDemandDone, String host, String failoverPartner, String protocol, SqlInternalConnectionTds connHandler, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, SqlConnection owningObject, Boolean aliasLookup)
at System.Data.SqlClient.SqlInternalConnectionTds.Ope nLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance)
at System.Data.SqlClient.SqlInternalConnectionTds..ct or(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance)
at System.Data.SqlClient.SqlConnectionFactory.CreateC onnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection)
at System.Data.ProviderBase.DbConnectionFactory.Creat ePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options)
at System.Data.ProviderBase.DbConnectionPool.CreateOb ject(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionPool.UserCrea teRequest(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionPool.GetConne ction(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionFactory.GetCo nnection(DbConnection owningConnection)
at System.Data.ProviderBase.DbConnectionClosed.OpenCo nnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
at System.Data.SqlClient.SqlConnection.Open()
at DBManager.SqlDBManager.ConnectToDB() in C:\Documents and Settings\Alessandro Del Piero\My Documents\Visual Studio 2005\Projects\DBManager\DBManager\SqlDBManager.cs: line 53
at DBModule.Form1.button2_Click(Object sender, EventArgs e) in G:\DBModule\DBModule\Form1.cs:line 205 --------------------------- OK ---------------------------
Do you mind explaining to me how the connection string written their works?
because i read through it and then tried to use that connection string (of
course with my own db name) but the string is not a valid C# string, i mean
|DataDirectory| as its mentioned in the description is a keyword but its just
hanging there outside the qoutes and of course it didnt compile as it was, i
tried some other combinations, they didnt work either, so can u please either
tell me the correct connection string, or give me an example?
"Nicholas Paldino [.NET/C# MVP]" wrote: Alex,
Check this link, it will tell you how to create a connection to SQL Server and attach to a database file:
http://msdn2.microsoft.com/en-us/library/ms165716.aspx
Hope this helps.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com
"AlexDP" <Al****@discussions.microsoft.com> wrote in message news:6B**********************************@microsof t.com... My program has to access an SQL Server DB file that is in the same folder as the executable. i dont want to setup a server. i was able to do this on my own computer, the program would access any sql server db file without it being attached to the server. When i take it to another system it fails to run. All systems have SQL Server Express and SQL Server 2005 installed.
Can someone please direct me through the steps to fix this problem?
There are 2 errors (on different pcs) i get when i try to access the db one is:
Error 1
Generating user instances in SQL Server is disabled. Use sp_configure 'user instances enabled' to generate user instances.
--------------------------- Error 2 --------------------------- System.Data.SqlClient.SqlException: An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
at System.Data.SqlClient.SqlInternalConnection.OnErro r(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndW arning(TdsParserStateObject stateObj)
at System.Data.SqlClient.TdsParser.Connect(Boolean& useFailoverPartner, Boolean& failoverDemandDone, String host, String failoverPartner, String protocol, SqlInternalConnectionTds connHandler, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, SqlConnection owningObject, Boolean aliasLookup)
at System.Data.SqlClient.SqlInternalConnectionTds.Ope nLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance)
at System.Data.SqlClient.SqlInternalConnectionTds..ct or(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance)
at System.Data.SqlClient.SqlConnectionFactory.CreateC onnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection)
at System.Data.ProviderBase.DbConnectionFactory.Creat ePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options)
at System.Data.ProviderBase.DbConnectionPool.CreateOb ject(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionPool.UserCrea teRequest(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionPool.GetConne ction(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionFactory.GetCo nnection(DbConnection owningConnection)
at System.Data.ProviderBase.DbConnectionClosed.OpenCo nnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
at System.Data.SqlClient.SqlConnection.Open()
at DBManager.SqlDBManager.ConnectToDB() in C:\Documents and Settings\Alessandro Del Piero\My Documents\Visual Studio 2005\Projects\DBManager\DBManager\SqlDBManager.cs: line 53
at DBModule.Form1.button2_Click(Object sender, EventArgs e) in G:\DBModule\DBModule\Form1.cs:line 205 --------------------------- OK ---------------------------
I'm not sure where your problem is, but here are a couple pointers..
The string you are referring to should be a valid C# string..
"|DataDirectory|" should be replaced with your local database
directory.
The @ character proceeding the string means the string should be taken
literally.
The following string:
@"Data Source='.\SQLExpress'; Initial Catalog=; Integrated
Security=true; AttachDBFileName='" + |DataDirectory| + @"\MyDb.mdf'";
is equivalent to:
""Data Source='.\SQLExpress'; Initial Catalog=; Integrated
Security=true; AttachDBFileName='"" + |DataDirectory| + ""\MyDb.mdf'"";
A guide to accessing SQL: http://www.codeproject.com/cs/databa..._in_csharp.asp
Hope that helps,
-A.Kahtava This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Michel |
last post by:
Hi,
I like to build a small simple dinamic website: Point-of-sale
(detail-shop), So entering stock, logging all sales, print out
invoices and download the logs to be imported into Excel.
I...
|
by: Scott Castillo |
last post by:
Is it possible to access an SQL Server database from a Javascript client? I
know you can transfer variables from middleware to Javascript client, but
was wondering if you can directly access...
|
by: prodirect |
last post by:
Hi all,
I hope someone can help me. I've recently created a database and wanted to
put it up on an ftp sight so that multiple people could access the same
tables at the same time from different...
|
by: kai |
last post by:
Hi, All
I try to block some one import my Access database tables using Access
database.
I used password protection, but if some one crack through my password, are
there any other methods to...
|
by: shineofleo |
last post by:
Here is the situation: I wrote a VB programm, which stores all the
information in a single Access database file using jet engine. It
worked well, however one of my customs reported that there was...
|
by: Navodit |
last post by:
I have 3 dropdowns in my application. Based on the selections made in the
first two dropdowns, I need to pull out data from the database to set up the
corresponding menu for the third dropdown. How...
|
by: sampalmer21 |
last post by:
Is it at all possible to access a sql database, whether reading it or storing values to it, without having sql server installed or running as a process in the background? Perhaps this can be done...
|
by: MartinJackson |
last post by:
Using SQL Server 2005 Express.
I want to create and maintain the SQL database and tables from within a VB6 application. First I need to create an empty database file. This I can't do.
Using...
|
by: santhanalakshmi |
last post by:
Hi,
I am trying to open database file(.mdf) using enterprise manager.
Right Click on Databases -> All Tasks -> Attach database
I am browsing the .mdf...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |