| | |
Error 1 Operator '&' cannot be applied to operands of type 'string' and 'string'
Please support our ASP.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Nov 2008
Posts: 19
Reputation:
Solved Threads: 0
i taken the three textboxes and one button to store the data in sqlserver .but the it giving the error.
the code is as follows...
i written the code like that .please clarify my application..
if it is not correct please tel me the correct...
the code is as follows...
ASP.NET Syntax (Toggle Plain Text)
using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Data.SqlClient; public partial class Default3 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { SqlConnection con = new SqlConnection("user id=sa;password=vikram;database=kran"); SqlCommand cmd = new SqlCommand("select * from dr", con); SqlDataReader dr; // cmd.CommandText = "select * from dr"; cmd.Connection = con; con.Open(); dr = cmd.ExecuteReader(); cmd.CommandText="insert into dr values("&TextBox1.Text&", ' " &TextBox2.Text&" ', ' " &TextBox3.Text&" ')"; TextBox1.Text=" "; TextBox2.Text= " "; TextBox3.Text=" "; dr.Close(); con.Close(); } protected void Button1_Click(object sender, EventArgs e) { } }
i written the code like that .please clarify my application..
if it is not correct please tel me the correct...
Last edited by peter_budo; Nov 14th, 2008 at 8:09 pm. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
•
•
Join Date: Nov 2008
Posts: 19
Reputation:
Solved Threads: 0
Error 1 Operator '&' cannot be applied to operands of type 'string' and 'string'
0
#4 Nov 14th, 2008
hai to all,,
once again i am sending the same code.but it giving same problem.please rectify my problem .it is urgent to me...
Error comes at bold line code..
please forward me a correct code..
once again i am sending the same code.but it giving same problem.please rectify my problem .it is urgent to me...
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("user id=sa;password=vikram;database=kum");
SqlCommand cmd = new SqlCommand(" ", con);
con.Open();
con.Close();
}
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection con=new SqlConnection("user id=sa;password=vikram;database=kum");
SqlCommand cmd=new SqlCommand();
cmd.CommandText = "insert into kumar values( " & TextBox1.Text & " ,' " & TextBox2.Text & " ')";
con.Open();
cmd.ExecuteNonQuery();
con.Close();
TextBox1.Text = " ";
TextBox2.Text=" ";
}
}please forward me a correct code..
Last edited by peter_budo; Nov 14th, 2008 at 8:11 pm. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
•
•
Join Date: May 2008
Posts: 144
Reputation:
Solved Threads: 9
Re: Error 1 Operator '&' cannot be applied to operands of type 'string' and 'string'
0
#5 Nov 14th, 2008
use "+" instead of "&"
like
cmd.CommandText = "insert into kumar values( " + TextBox1.Text + " ,' " + TextBox2.Text + " ')";
like
cmd.CommandText = "insert into kumar values( " + TextBox1.Text + " ,' " + TextBox2.Text + " ')";
![]() |
Other Threads in the ASP.NET Forum
- Previous Thread: Page.RegisterClientScriptBlock
- Next Thread: need to populate the single column out of mulitple colums,
| Thread Tools | Search this Thread |
Tag cloud for ASP.NET
.net 2.0 activexcontrol advice ajax alltypeofvideos anathor application asp asp.net bc30451 bottomasp.net box browser button c# checkbox click commonfunctions confirmationcodegeneration css dataaccesslayer database datagridview datagridviewcheckbox datalist deadlock development dgv dropdownlist dynamically edit expose feedback fileuploader fill flash form formatdecimal forms formview google grid gridview gudi iframe iis javascript list listbox login microsoft mono mouse mssql multistepregistration news numerical objects opera panelmasterpagebuttoncontrols parent project radio redirect registration relationaldatabases reportemail richtextbox rotatepage save schoolproject search security select silverlight smartcard smoobjects software sql-server sqlserver2005 suse textbox tracking unauthorized validation vb.net video videos view virtualdirectory vista visualstudio web webapplications webdevelopemnt webprogramming webservice xsl youareanotmemberofthedebuggerusers





