Sorry to post again, I think the other one has been forgotton
I have a Windows Form, (Application). On that I have a TextBox called txtIdNum, a Button, and a TextBox called TxtNombre
What i want to happen is when someone types into the txtbox txtIdNum, and press the button, the code will search the MSQL table, and select all the fields where FIELD IDNum is = txtIdNum.Text
Straight forward, easy to say.
My code is the following
System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection("SERVER=localhost;DATABASE=test1;UID=sa");
System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand("SELECT * FROM tbl1 WHERE IDNum = '" + txtIdNum.Text + "'", conn);
System.Data.DataSet ds = new System.Data.DataSet("MyDataSet");
txtNombre.Text = Convert.ToString(cmd.ExecuteScalar());
When I run the script, The Last line, ExecuteScalar() says that the connection is not alive.
Ok
I was told the default Username and Password for the SQL table was Username = sa, password = "" (Nothing)
How do I test that the connection is working. Or what is the default username and password, or am i missing something in the code.
Thanks in advance

Connection not Alive
Mysticone
Please try using Windows Authentication.
Ex:
connectionString="Data Source=ComputerName\SQLEXpress;Initial Catalog=DataBaseName;Integrated Security=True";
Thanks.
bhat
SingWei
SQL Server 2005 Express is installed with a default instance name of Computer Name\SQLEXPRESS.
Please use Connection String as
Ex:
connectionString="Data Source=ComputerName\SqlExpress;Initial Catalog=DataBaseName;User ID=UserID;Password=Pwd"
Thanks.
bduffy
I do not know the username and password for MSQL
I un-installed and re-installed. It did not ask me for a username or password.
People say there is no default, it is set up when you install SQL. But Visual Studio installed it, and did not ask me for a username or password
Mincheoul Kim
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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
HELP ME PLEASE!!!!
Dayan_07
In the above posted code, you do not seem to open the database Connection
After creating the Connection object "conn" ,please add statement -
conn.Open();
Thanks.
Khan16688
Still getting
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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
and Yes I have restarted
I do want the SQL built into the application. Is there a way to connect internal
Craig Harry - Microsoft