|
-
Mar 31st, 2008, 01:09 PM
#1
Thread Starter
Member
VB.NET app deployment
I have an VB.NET app that connects to a local SQL SERVER EXPRESS database
On the computer I developed the application everything works ok but when I try to deploy the application on another computer with SQL SERVER EXPRESS installed an error message appears : << under the default settings SQL SERVER does not allow remote connections. (provider :SQL Network Interfaces, error 26 : Error Locating Server/Instance Specified) >>
Is it the connection string that is bad or the fact the on my machine I have an SQL SERVER EXPRESS instance named COMPUTER\MYNAME and on the deployment machine I have another instance name
-
Mar 31st, 2008, 01:18 PM
#2
Re: VB.NET app deployment
If using SQL Express then ComputerName\SQLExpress (this is a named instance).
Sometimes the Programmer
Sometimes the DBA
Mazz1
-
Apr 1st, 2008, 02:28 AM
#3
Thread Starter
Member
Re: VB.NET app deployment
that's exactly my problem ... ComputerName is different for every computer I install the application ... it must be an environment variable that emulates the ComputerName in VB.NET
For example if my computer has ComputerName='MAKKO' and the computer I must install the application has the ComputerName='SOMETHINGELSE' on my computer the environment variable has to be MAKKO and on other computer the environment variable should be SOMETHINGELSE
-
Apr 1st, 2008, 02:36 AM
#4
Re: VB.NET app deployment
You shouldn't be using the machine name at all. This is from www.connectionstrings.com:
Data Source=.\SQLExpress;Integrated Security=true;AttachDbFilename=|DataDirectory|\mydb.mdf;User Instance=true;
That is also what VS does by default when you add a SQL Server database to your project.
You can also use "(local)" instead of the dot.
-
Apr 1st, 2008, 05:21 AM
#5
Thread Starter
Member
Re: VB.NET app deployment
thank you jmcilhinney ...
So i should use Data Source=.\SQLExpress; if I install an SQLExpress named instance
If i decide to install the default instance I would use Data Source=.; or
Data Source=(local); ???
And another question regarding SQL SERVER instalation ... At the 4th step of instalation USE THE BUILT IN SYSTEM ACCOUNT ... Should I choose Local System ? or Local Service / Network
Last edited by makko; Apr 1st, 2008 at 05:30 AM.
-
Apr 1st, 2008, 07:15 AM
#6
Thread Starter
Member
Re: VB.NET app deployment
If I enter myself the following code :
AppDomain.CurrentDomain.SetData("DataDirectory", "C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data")
Dim sqlconn As String = "Server=.;AttachDbFilename=|DataDirectory|test.mdf;Database=test;Trusted_Connection=Yes;"
string strSQL = “select * from table1”;
SqlDataAdapter dataAdapter = new SqlDataAdapter(strSQL, strCon);
SqlCommandBuilder commandBuilder = new SqlCommandBuilder(dataAdapter);
DataTable table = new DataTable();
table.Locale = System.Globalization.CultureInfo.InvariantCulture;
dataAdapter.Fill(table);
dbBindSource.DataSource = table;
dbGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCellsExceptHeader);
dbGridView.ReadOnly = true;
dbGridView.DataSource = dbBindSource;
I get the result I want ...
But sometime I need to bind the tables to datagridview not from code but from designer ... And the designer creates automaticly an connection string like "Data Source=MYCOMPUTERNAME;Initial Catalog=test;Integrated Security=True"
What can I do so the designer creates an connection string like "Server=.;AttachDbFilename=|DataDirectory|test.mdf;Database=test;Trusted_Connection=Yes;"
Thx
-
Apr 1st, 2008, 07:42 AM
#7
Re: VB.NET app deployment
SQLExpress is always a named instance. You don't have a choice in that.
Sometimes the Programmer
Sometimes the DBA
Mazz1
-
Apr 1st, 2008, 01:40 PM
#8
Thread Starter
Member
Re: VB.NET app deployment
I resolved the problem ...
At the SqlServerExpress instalation :
- selected the 'default' instance
- selected the 'local system'
In the code if I want to connect without designer I create myself the connection string like "Server=.;AttachDbFilename=|DataDirectory|test.mdf;Database=test;Trusted_Connection=Yes;"
If I want to connect with designer the connection strings will look like "Data Source=MYCOMPUTERNAME;Initial Catalog=test;Integrated Security=True"
and I will replace mannualy the MYCOMPUTERNAME string with '.' character
For me that worked very well
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|