connectivity with database
-
hi, i am using visual studio 2008 and making project in c#. i had created web application form but i am not able to connect it with database. em using sqlserver2005 as database
shubhi
-
hi, i am using visual studio 2008 and making project in c#. i had created web application form but i am not able to connect it with database. em using sqlserver2005 as database
shubhi
What do you mean by "not able to connect it with database"?? What does you code look like that does the connection and query work?? What are the error messages you're getting?? Just saying "it doesn't work" doesn't help you.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak -
What do you mean by "not able to connect it with database"?? What does you code look like that does the connection and query work?? What are the error messages you're getting?? Just saying "it doesn't work" doesn't help you.
A guide to posting questions on CodeProject[^]
Dave Kreskowiaki am not able o make connection con
-
i am not able o make connection con
shubham salwan wrote:
i am not able o make connection con
You do realize that we cannot see your code, or have your project available, or read your mind. If you expect to get help for your problems, you have to show the code that you are having trouble with and share the errors you are getting. We cannot possibly help you resolve issues if you do not give us the information that is needed to help you! Do you call your mechanic and tell him that your car is "broke" and expect that they should know eactly what you mean the problem is?
Why is common sense not common? Never argue with an idiot. They will drag you down to their level where they are an expert. Sometimes it takes a lot of work to be lazy Please stand in front of my pistol, smile and wait for the flash - JSOP 2012
-
shubham salwan wrote:
i am not able o make connection con
You do realize that we cannot see your code, or have your project available, or read your mind. If you expect to get help for your problems, you have to show the code that you are having trouble with and share the errors you are getting. We cannot possibly help you resolve issues if you do not give us the information that is needed to help you! Do you call your mechanic and tell him that your car is "broke" and expect that they should know eactly what you mean the problem is?
Why is common sense not common? Never argue with an idiot. They will drag you down to their level where they are an expert. Sometimes it takes a lot of work to be lazy Please stand in front of my pistol, smile and wait for the flash - JSOP 2012
private void button1_Click(object sender, EventArgs e)
{
string connString = "Data Source=shubhi-PC;Initial Catalog=employee;uid=sa;pass=abc;Integrated Security=True"; SqlConnection conn = new SqlConnection(connString);
conn.Open();
String sql = "INSERT INTO emp_detail(empid,empname,empadd,empsal) values ('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "','" + textBox4.Text + "')";cmd.ExecuteNonQuery(); conn.Close(); textBox1.Text="";
i want to save data to sqlserver2005 ... bt itz not working
-
private void button1_Click(object sender, EventArgs e)
{
string connString = "Data Source=shubhi-PC;Initial Catalog=employee;uid=sa;pass=abc;Integrated Security=True"; SqlConnection conn = new SqlConnection(connString);
conn.Open();
String sql = "INSERT INTO emp_detail(empid,empname,empadd,empsal) values ('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "','" + textBox4.Text + "')";cmd.ExecuteNonQuery(); conn.Close(); textBox1.Text="";
i want to save data to sqlserver2005 ... bt itz not working
shubham salwan wrote:
bt itz not working
Of course it's not working. Your connection string has a user name a password and you are telling it to use integrated security. Not to mention that you did not bother even defining a command object. You do realize that this won't even compile don't you?
Why is common sense not common? Never argue with an idiot. They will drag you down to their level where they are an expert. Sometimes it takes a lot of work to be lazy Please stand in front of my pistol, smile and wait for the flash - JSOP 2012
-
shubham salwan wrote:
bt itz not working
Of course it's not working. Your connection string has a user name a password and you are telling it to use integrated security. Not to mention that you did not bother even defining a command object. You do realize that this won't even compile don't you?
Why is common sense not common? Never argue with an idiot. They will drag you down to their level where they are an expert. Sometimes it takes a lot of work to be lazy Please stand in front of my pistol, smile and wait for the flash - JSOP 2012
Shhhhhhhh.... Don't tell him his code is subject to SQL Injection attacks either :rolleyes:
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
-
Shhhhhhhh.... Don't tell him his code is subject to SQL Injection attacks either :rolleyes:
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
I figure he has enough trouble without throwing gasoline on the bonfire.
Why is common sense not common? Never argue with an idiot. They will drag you down to their level where they are an expert. Sometimes it takes a lot of work to be lazy Please stand in front of my pistol, smile and wait for the flash - JSOP 2012
-
private void button1_Click(object sender, EventArgs e)
{
string connString = "Data Source=shubhi-PC;Initial Catalog=employee;uid=sa;pass=abc;Integrated Security=True"; SqlConnection conn = new SqlConnection(connString);
conn.Open();
String sql = "INSERT INTO emp_detail(empid,empname,empadd,empsal) values ('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "','" + textBox4.Text + "')";cmd.ExecuteNonQuery(); conn.Close(); textBox1.Text="";
i want to save data to sqlserver2005 ... bt itz not working
Don't make your SQL statements that way -- use a parameterized query.
-
hi, i am using visual studio 2008 and making project in c#. i had created web application form but i am not able to connect it with database. em using sqlserver2005 as database
shubhi
When you use "
Integrated Security=True
" in your connection string, the user and password given there are ignored - the current Windows user is used for login to the database instead.