databinding textbox to a database
-
Hi guys, I am beginner in ASP.NET Programming. I want to know one thing, what is think really simple. I have a textbox and a button, and I would like the text what will be entered in the textbox to be added in the table in the database. If is possible, in C# language, cause I am using that language. Thanks ahead
-
Hi guys, I am beginner in ASP.NET Programming. I want to know one thing, what is think really simple. I have a textbox and a button, and I would like the text what will be entered in the textbox to be added in the table in the database. If is possible, in C# language, cause I am using that language. Thanks ahead
-
laziale wrote:
I am beginner
Now that you've said that, I recommend you to do some research using google.
Give a man a fish, he'll eat for a day. Teach a man how to fish, he'll eat for lifetime. Pradeep Joe
-
use the following : -
1. Import the SqlClient namespace 2. Create the object of SQL Connect to bind with SQLServer SQLConnection con=new SQLConnection("Initial Catelog=test;Data Source=.;user id=sa;password=pwd"); here Data Source is the computer name on which the database in created Initial Catelog is the database name available on the server user id is the user id for database as on password 3. Now create the command object to give the sql command to the sever SQLCommand cmd=new SQLCommand(sqlstr,con); here con is the object for connection and sqlstr is the query to execute like in our case it is "insert into tbltest values ('" + txtname.text + "')" 4. Now Execute the command using cmd object cmd.ExecuteNonQuery(); Remember to open the connection using con.Open() before xecution of Query.
If fell any trouble then plz reply With Regards Yogesh Agarwal -
use the following : -
1. Import the SqlClient namespace 2. Create the object of SQL Connect to bind with SQLServer SQLConnection con=new SQLConnection("Initial Catelog=test;Data Source=.;user id=sa;password=pwd"); here Data Source is the computer name on which the database in created Initial Catelog is the database name available on the server user id is the user id for database as on password 3. Now create the command object to give the sql command to the sever SQLCommand cmd=new SQLCommand(sqlstr,con); here con is the object for connection and sqlstr is the query to execute like in our case it is "insert into tbltest values ('" + txtname.text + "')" 4. Now Execute the command using cmd object cmd.ExecuteNonQuery(); Remember to open the connection using con.Open() before xecution of Query.
If fell any trouble then plz reply With Regards Yogesh Agarwaland what should I write for the button onclick action?? Btw thx for the previous reply, I appreciated, and it really help me. and I get one error for connection con.open: 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 what should I write for the button onclick action?? Btw thx for the previous reply, I appreciated, and it really help me. and I get one error for connection con.open: 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)
The code i gave could be written on button click event and if you receive this message then check you connection string is it correct?? Yogesh Agarwal
-
The code i gave could be written on button click event and if you receive this message then check you connection string is it correct?? Yogesh Agarwal