i am using the database SQLSERver 2005, i m new to this i worked in sql server2000... but using sqlserver 2005 i dont know how to insert the values...
i write the code but the values is not storing in the database if anybody knows plz help me...
sql server2005
server type: database Engine
authentication :windows authentication
here is my code
private void butinsert_Click (object sender, EventArgs e)
{
SqlConnection con=new SqlConnection(" server=localhos t;user id=sa;password= ;database=D:\\c ompany");
SqlCommand cmd=new SqlCommand("ins ert into emp(name,age,sa lary) values('"+txtna me.Text+"','"+t xtage.Text+"',' "+txtsalary.Tex t+"')",con);
con.Open();
int i;
i=cmd.ExecuteNo nQuery();
if(i>0)
{
Console.WriteLi ne("inserted Successfully");
}
con.Close();
}
it showing this errors:::
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)
i write the code but the values is not storing in the database if anybody knows plz help me...
sql server2005
server type: database Engine
authentication :windows authentication
here is my code
private void butinsert_Click (object sender, EventArgs e)
{
SqlConnection con=new SqlConnection(" server=localhos t;user id=sa;password= ;database=D:\\c ompany");
SqlCommand cmd=new SqlCommand("ins ert into emp(name,age,sa lary) values('"+txtna me.Text+"','"+t xtage.Text+"',' "+txtsalary.Tex t+"')",con);
con.Open();
int i;
i=cmd.ExecuteNo nQuery();
if(i>0)
{
Console.WriteLi ne("inserted Successfully");
}
con.Close();
}
it showing this errors:::
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)
Comment