A
Alex
I run the following and I get a messagebox telling me the connection
is closed (OK so far) and then it crashes. The error message is: SQL
Server does not exist or access denied.
SQL Manager is running and I tested it by running an older ADO
assignment (which worked). So I'm not sure what I'm doing wrong with
the following bare-bones code...
My code follows.
===
using System;
using System.Windows.Forms;
using System.Data.SqlClient;
public class ConnectionTest
{
public static void Main()
{
try
{
SqlConnection myConnection = new SqlConnection("Initial
Catalog=Northwind;Data Source=localhost;Integrated Security=SSPI;");
MessageBox.Show("Connection is " +
myConnection.State.ToString());
myConnection.Open();
MessageBox.Show("Connection is " +
myConnection.State.ToString());
myConnection.Close();
MessageBox.Show("Connection is " +
myConnection.State.ToString());
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
is closed (OK so far) and then it crashes. The error message is: SQL
Server does not exist or access denied.
SQL Manager is running and I tested it by running an older ADO
assignment (which worked). So I'm not sure what I'm doing wrong with
the following bare-bones code...
My code follows.
===
using System;
using System.Windows.Forms;
using System.Data.SqlClient;
public class ConnectionTest
{
public static void Main()
{
try
{
SqlConnection myConnection = new SqlConnection("Initial
Catalog=Northwind;Data Source=localhost;Integrated Security=SSPI;");
MessageBox.Show("Connection is " +
myConnection.State.ToString());
myConnection.Open();
MessageBox.Show("Connection is " +
myConnection.State.ToString());
myConnection.Close();
MessageBox.Show("Connection is " +
myConnection.State.ToString());
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}