| | |
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 |
.net 2.0 3.5 ajax alltypeofvideos appliances asp asp.net beginner box browser businesslogiclayer button c# cac checkbox class commonfunctions compatible content contenttype control countryselector courier dataaccesslayer database datagrid datagridview datalist deployment development dgv dialog dropdownlist dropdownmenu dynamic dynamically edit embeddingactivexcontrol fileuploader fill findcontrol flash flv formview gridview gudi iis javascript list listbox login menu microsoft mouse mssql nameisnotdeclared news novell numerical opera order panelmasterpagebuttoncontrols problem radio ratings redirect registration relationaldatabases reportemail schoolproject search security serializesmo.table sessionvariables silverlight smoobjects software sql sql-server sqlserver2005 ssl tracking treeview validatedate validation vb.net videos vista visual-studio visualstudio vs2008 web webapplications webarchitecture webdevelopment webprogramming webservice wizard xsl





