| | |
how to connect and querysql ASP.NET BY USING C# CODE
Please support our ASP.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Mar 2008
Posts: 2
Reputation:
Solved Threads: 0
Hello everyone,
I was wondering if anyone could tell me how to connect and query sql databases in ASP.NET
Using c # code
I try to use this code, but there is some mistake in the code lead to an error message
You must first withdraw from sqlDataadapter toolbar to connect to the structural language queries
using System.Data;
using System.Data.SqlClient;
{ string n1,n2,n3,n4;
n1=TextBox1.Text;
n2=TextBox2.Text;
n3=TextBox3.Text;
n4=TextBox4.Text;
Conn1.Open();
Adapter1.InsertCommand=new SqlCommand("Insert Into TEST1 Values('"+n1+"','"+n2+"','"+n3+"','"+n4+"')",Conn1);
Adapter1.InsertCommand.ExecuteNonQuery();
Conn1.Close();
}
Thank you in advance
I was wondering if anyone could tell me how to connect and query sql databases in ASP.NET
Using c # code
I try to use this code, but there is some mistake in the code lead to an error message
You must first withdraw from sqlDataadapter toolbar to connect to the structural language queries
using System.Data;
using System.Data.SqlClient;
{ string n1,n2,n3,n4;
n1=TextBox1.Text;
n2=TextBox2.Text;
n3=TextBox3.Text;
n4=TextBox4.Text;
Conn1.Open();
Adapter1.InsertCommand=new SqlCommand("Insert Into TEST1 Values('"+n1+"','"+n2+"','"+n3+"','"+n4+"')",Conn1);
Adapter1.InsertCommand.ExecuteNonQuery();
Conn1.Close();
}
Thank you in advance
•
•
Join Date: Mar 2008
Posts: 2
Reputation:
Solved Threads: 0
Hello everyone,
I was wondering if anyone could tell me how to connect and query sql databases in ASP.NET
Using c # code
I try to use this code, but there is some mistake in the code lead to an error message
You must first withdraw from sqlDataadapter toolbar to connect to the structural language queries
using System.Data;
using System.Data.SqlClient;
{ string n1,n2,n3,n4;
n1=TextBox1.Text;
n2=TextBox2.Text;
n3=TextBox3.Text;
n4=TextBox4.Text;
Conn1.Open();
Adapter1.InsertCommand=new SqlCommand("Insert Into TEST1 Values('"+n1+"','"+n2+"','"+n3+"','"+n4+"')",Conn1);
Adapter1.InsertCommand.ExecuteNonQuery();
Conn1.Close();
}
Thank you in advance
I was wondering if anyone could tell me how to connect and query sql databases in ASP.NET
Using c # code
I try to use this code, but there is some mistake in the code lead to an error message
You must first withdraw from sqlDataadapter toolbar to connect to the structural language queries
using System.Data;
using System.Data.SqlClient;
{ string n1,n2,n3,n4;
n1=TextBox1.Text;
n2=TextBox2.Text;
n3=TextBox3.Text;
n4=TextBox4.Text;
Conn1.Open();
Adapter1.InsertCommand=new SqlCommand("Insert Into TEST1 Values('"+n1+"','"+n2+"','"+n3+"','"+n4+"')",Conn1);
Adapter1.InsertCommand.ExecuteNonQuery();
Conn1.Close();
}
Thank you in advance
•
•
Join Date: Mar 2008
Posts: 1
Reputation:
Solved Threads: 0
I think you must try this code-----
using System.Data;
using System.Data.SqlClient;
{
string n1,n2,n3,n4;
n1=TextBox1.Text;
n2=TextBox2.Text;
n3=TextBox3.Text;
n4=TextBox4.Text;
string qr=Insert Into TEST1 Values('"+n1+"','"+n2+"','"+n3+"','"+n4+"')";
SqlConnection scon=new SqlConnection("server=your computername;uid=sa;pwd=sqlpassword;database=databasename");
SqlDataAdapter sda=new SqlDataAdapter(qr,scon);
DataSet ds=new DataSet();
sda.Fill(ds);
next to this bind it to your dataview or datagrid....
Hope this code will be helpfull
}
using System.Data;
using System.Data.SqlClient;
{
string n1,n2,n3,n4;
n1=TextBox1.Text;
n2=TextBox2.Text;
n3=TextBox3.Text;
n4=TextBox4.Text;
string qr=Insert Into TEST1 Values('"+n1+"','"+n2+"','"+n3+"','"+n4+"')";
SqlConnection scon=new SqlConnection("server=your computername;uid=sa;pwd=sqlpassword;database=databasename");
SqlDataAdapter sda=new SqlDataAdapter(qr,scon);
DataSet ds=new DataSet();
sda.Fill(ds);
next to this bind it to your dataview or datagrid....
Hope this code will be helpfull
}
Last edited by sagar.deshmukh; Mar 10th, 2008 at 9:32 am.
![]() |
Other Threads in the ASP.NET Forum
- Previous Thread: How to create watermark image at runtime in c#
- Next Thread: Merging static and databound items in dropdownlists
| Thread Tools | Search this Thread |
.net 2.0 3.5 activexcontrol advice ajax alltypeofvideos asp asp.net bc30451 bottomasp.net browser businesslogiclayer button c# c#gridviewcolumn checkbox click commonfunctions compatible confirmationcodegeneration content contenttype courier css dataaccesslayer database datagrid datagridview datagridviewcheckbox datalist deadlock development dgv dropdownlist dropdownmenu edit expose flash flv formatdecimal forms formview gridview homeedition iframe iis javascript jquery list listbox login menu microsoft mono mouse mssql multistepregistration nameisnotdeclared news numerical objects order panelmasterpagebuttoncontrols problem radio ratings reportemail rotatepage save schoolproject search security serializesmo.table silverlight smartcard software sql-server sqlserver2005 suse textbox tracking unauthorized validation vb.net video videos virtualdirectory vista visual-studio visualstudio web webapplications webarchitecture webdevelopemnt webprogramming webservice wizard xml youareanotmemberofthedebuggerusers





