June 17, 2009 at 1:42 am
Hi All,
I need help with a situation that has me bamboozled.
I have a C# application that runs on XP, Vista and Windows 7 RC.
I have installed a SQL Server Express 2008 instance onto XP, Vista and Windows 7 RC.
The Vista PC is on a client site, the XP and Win7 PCs are in my office.
When I run the app, it loads regardless of O/S. When the app attempts to open a connection to the SQL database, it fails on the Vista instance.
I have successfully opened the XP/Win7 databases from a remote PC, but the Vista one fails to allow me in.
However, I can open the database on the Vista PC, using the management express console. What am I missing?
I have opened ports 1433 and 1434 on my router. I opened the same ports in my Firewall, and even turned the firewall off. This made no difference.
I have TCP/IP turned on, Remote Connections turned on, logged in as administrator. Nothing seems to make a difference.
The fact that I can connect via the Management Console indicates to me that the Vista SQL instance is operating correctly and is ready for use. This seems to indicate that my app settings are incorrect.
The fact that the app connects to the XP/Win7 instances indicates that the Vista SQL is not configured properly.
Am I missing something obvious or is there an issue with SQL 2008 on Vista? :unsure:
Cheers,
Mark Chimes
June 17, 2009 at 2:36 am
MS changed many things for UAC in Windows 7. This might be the reason why it doesn't work on Vista. However, I used SSE2k8 on Vista with no problems. Currently I have no Vista environment to test but I know that it worked on my system.
Could you post the error (including the inner exceptions) you get, please?
Do you use SQL Server native client or OLEDB? Could you post your connection string, please?
If you work with SqlClient to connect database you can use the following Exception-Handler to get complete SQL exception information:
public override void Run()
{
using (SqlConnection cn = new SqlConnection("Server=(local);Database=Sandbox;Integrated Security=SSPI"))
{
try
{
cn.Open();
// The info message handler can be used for PRINT messages from server
cn.InfoMessage += new SqlInfoMessageEventHandler(cn_InfoMessage);
using (SqlCommand cmd = new SqlCommand())
{
cmd.Connection = cn;
cmd.CommandType = CommandType.Text;
// Use PRINT
cmd.CommandText = "PRINT 'Hello world'";
}
cn.InfoMessage -= new SqlInfoMessageEventHandler(cn_InfoMessage);
}
catch (Exception ex)
{
#region Log complete exception
StringWriter sw = new StringWriter();
sw.WriteLine();
sw.WriteLine();
#region Log main information
sw.WriteLine();
sw.WriteLine();
sw.WriteLine("####################################################");
sw.WriteLine("# -> EXCEPTION LOGGING");
sw.WriteLine();
sw.WriteLine("---------------------");
sw.WriteLine("STACK TRACE:");
sw.WriteLine(ex.StackTrace);
sw.WriteLine();
#endregion
while (ex != null)
{
#region Log all nested exceptions
sw.WriteLine("===========================");
sw.WriteLine("EXCEPTION");
sw.WriteLine("Type: {0}", ex.GetType());
sw.WriteLine("Message: {0}", ex.Message);
sw.WriteLine();
if (ex is SqlException)
{
#region Log special SqlException information
SqlException sqlEx = (SqlException)ex;
sw.WriteLine("Number: {0}", sqlEx.Number);
sw.WriteLine("Procedure: {0}", sqlEx.Procedure ?? "");
sw.WriteLine("State: {0}", sqlEx.State);
foreach (SqlError e in sqlEx.Errors)
{
sw.WriteLine();
sw.WriteLine("----------------------");
sw.WriteLine("SQL ERROR");
sw.WriteLine("Message: {0}", e.Message);
sw.WriteLine("Number: {0}", e.Number);
sw.WriteLine("Procedure: {0}", e.Procedure ?? "");
sw.WriteLine("State: {0}", e.State);
}
#endregion
}
sw.WriteLine();
#endregion
ex = ex.InnerException;
}
#region Log footer
sw.WriteLine("# <- EXCEPTION LOGGING");
sw.WriteLine("####################################################");
#endregion
System.Diagnostics.Debug.WriteLine(sw.GetStringBuilder().ToString());
#endregion
}
}
}
static void cn_InfoMessage(object sender, SqlInfoMessageEventArgs e)
{
Console.WriteLine("PRINT message from SQL Server:");
Console.WriteLine(e.Message);
}
Flo
June 17, 2009 at 2:57 am
Hi Florian,
Thanks for the prompt reply.
I will be at the client's site on Friday so I'll get a copy of all the error messages.
Thanks for the code snippet - I'll try that too.
cheers,
Mark Chimes
June 17, 2009 at 5:17 pm
Hi Florian,
As requested, here is my connection string from my app.config file.
Cheers,
Mark Chimes
June 19, 2009 at 4:44 pm
Hi Florian,
My apologies. I see my connection string did not copy and paste correctly into my last post.
While on site on Friday, I also installed SQL Server Express 2008 onto an XP computer. The same errors result when trying to connect to this instance, so obviously the problem is not with the SQL install, but with the method/s I am employing to connect to the database.
I've done this hundreds of times before, so I need to go thru things with a fine tooth comb to identify the cause of the issue.
Cheers,
Mark Chimes
June 19, 2009 at 4:51 pm
Mark Chimes (6/19/2009)
My apologies. I see my connection string did not copy and paste correctly into my last post.
Nothing to apologize and thanks for this hint. I saw your post but thought this seems to be a little bit too less information. This site has problems with XML. After your current post I noticed the problem with the displaying. If you use "Quote" on your previous post you can see your connection string:
<connectionStrings>
<add name="DOORman.Properties.Settings.connDOORmanSQL" connectionString="Data Source=SERVER2003\SQLEXPRESS;Initial Catalog=DOORman;User ID=AppName;Password=xxxxxx"
providerName="System.Data.SqlClient" />
</connectionStrings>
Looks find for me. Just the server name. Is it XP or Windows Server 2003?
While on site on Friday, I also installed SQL Server Express 2008 onto an XP computer. The same errors result when trying to connect to this instance, so obviously the problem is not with the SQL install, but with the method/s I am employing to connect to the database.
Did you get the exact error message and call stack?
Flo
Viewing 6 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply