Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
messi
Starting Member
47 Posts |
Posted - 2009-07-16 : 12:07:17
|
| finally the connection string work with methanks to afrikathen i mad save btnbut when i save the data it appears in data gridview but dont appeare in databasesave code:SqlConnection testcon = new SqlConnection(con); SqlCommand command = new SqlCommand("NewEmp", testcon); command.CommandType = CommandType.StoredProcedure; testcon.Open(); command.Parameters.Add("@Name", SqlDbType.NVarChar).Value = txtname.Text; command.Parameters.Add("@Branch", SqlDbType.NVarChar).Value = txtbranch.Text; command.Parameters.Add("@Salary", SqlDbType.Int).Value = txtsalary.Text; command.ExecuteNonQuery(); testcon.Close(); txtbranch.Text = ""; txtname.Text = ""; txtsalary.Text = "";can any one help |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-07-16 : 13:39:07
|
| can you post the procedure code too? Also did you try running profiler trace to see if save is happening? |
 |
|
|
afrika
Master Smack Fu Yak Hacker
2706 Posts |
Posted - 2009-07-16 : 16:01:33
|
quote: Originally posted by messiSqlConnection testcon = new SqlConnection(con); SqlCommand command = new SqlCommand("NewEmp", testcon); command.CommandType = CommandType.StoredProcedure; testcon.Open(); command.Parameters.Add("@Name", SqlDbType.NVarChar).Value = txtname.Text; command.Parameters.Add("@Branch", SqlDbType.NVarChar).Value = txtbranch.Text; command.Parameters.Add("@Salary", SqlDbType.Int).Value = txtsalary.Text; command.ExecuteNonQuery(); testcon.Close(); txtbranch.Text = ""; txtname.Text = ""; txtsalary.Text = "";can any one help
I dont fully understand what you are trying to do, but the line in red closes the connection while the lines in green, set the textboxes to nothing.What exactly are you trying to do ??? |
 |
|
|
afrika
Master Smack Fu Yak Hacker
2706 Posts |
Posted - 2009-07-16 : 16:01:55
|
| also next time, post this in the .net forum not sql |
 |
|
|
messi
Starting Member
47 Posts |
Posted - 2009-07-18 : 00:40:15
|
quote: Originally posted by visakh16 can you post the procedure code too? Also did you try running profiler trace to see if save is happening?
thanks for replayprocduer:Create Proc NewEmp(@name nvarchar(50),@Branch nvarchar(50),@Salary int)Asinsert into Employees (Emp_Name,Emp_Branch,Emp_Salary) values (@name ,@branch ,@Salary) |
 |
|
|
messi
Starting Member
47 Posts |
Posted - 2009-07-18 : 00:41:42
|
quote: Originally posted by afrika
quote: Originally posted by messiSqlConnection testcon = new SqlConnection(con); SqlCommand command = new SqlCommand("NewEmp", testcon); command.CommandType = CommandType.StoredProcedure; testcon.Open(); command.Parameters.Add("@Name", SqlDbType.NVarChar).Value = txtname.Text; command.Parameters.Add("@Branch", SqlDbType.NVarChar).Value = txtbranch.Text; command.Parameters.Add("@Salary", SqlDbType.Int).Value = txtsalary.Text; command.ExecuteNonQuery(); testcon.Close(); txtbranch.Text = ""; txtname.Text = ""; txtsalary.Text = "";can any one help
I dont fully understand what you are trying to do, but the line in red closes the connection while the lines in green, set the textboxes to nothing.What exactly are you trying to do ???
thanks for replayi want to free textbox after data saves in DB |
 |
|
|
messi
Starting Member
47 Posts |
Posted - 2009-07-18 : 00:52:42
|
quote: Originally posted by afrika also next time, post this in the .net forum not sql
i am sure i will |
 |
|
|
afrika
Master Smack Fu Yak Hacker
2706 Posts |
Posted - 2009-07-18 : 06:53:51
|
| do you get an error message ? |
 |
|
|
|
|
|
|
|