Hello everybody,
Oh man, I've been focused in trying to find a solution to my connection problem.
Well, I'll post the code once again along with the new error message I get when I run it.
Last updated code:
SqlConnection
objConn;
SqlCommand objCmd;
SqlDataReader objRdr;
objConn =
new SqlConnection("Server=SQLLOCAL;Database=Dorknozzle;Integrated Security=true");
objCmd =
new SqlCommand("Select * From Employees", objConn);
objConn.Open();
objRdr = objCmd.ExecuteReader();
while (objRdr.Read())
{
Response.Write(objRdr[
"Name"] + "<br />");
}
objRdr.Close();
objConn.Close();
Error Message:
"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. "
Now, I have researched the SQL remote issue and I have found a website that show me how to change these settings, this is the link: http://www.programmingado.net/a-395/SQL-Server-2005-Express-and-remote-connection.aspx
Well, at this point I really don't know what I'm looking for, I also tried the following code:
SqlConnectionStringBuilder bu = new SqlConnectionStringBuilder();
bu.DataSource =
@"OFFICE\SQLLOCAL"; //Where the OFFICE is the computer name and SQLLOCAL is the instance ... How can I know this settings, where are they located?
bu.InitialCatalog = /////// I just don't know what goes here. A member of the forum told me to put the database, but it does not work.
bu.IntegratedSecurity =
true;
SqlConnection conn = new SqlConnection();
conn.ConnectionString = bu.ConnectionString;
conn.Open();
objCmd =
new SqlCommand("Select * From Employees", objConn);
objRdr = objCmd.ExecuteReader();
while (objRdr.Read())
{
Response.Write(objRdr[
"Name"] + "<br />");
}
If someone can help me, I would greatly appreciate it.
Thanks,
Eduardo
Eduardo