| | |
error on search code
Please support our ASP.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Nov 2008
Posts: 19
Reputation:
Solved Threads: 0
hai friends i am writing the code for search button;
while i am wrote and complied that it gives the following error.
so many times i checked and posting into the forum now please clarify this problem..
code is:
Error Is:
please check the error and tell me the correct solution for that..
ASAP
another one is search information could be displayed in the browser in a tabular format.
please clarify my doubt.
please...please...please...please...please...please...please...please...
while i am wrote and complied that it gives the following error.
so many times i checked and posting into the forum now please clarify this problem..
code is:
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 nextpage : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { SqlConnection con = new SqlConnection("user id=sa;password=vikram;database=MUDIAM_INC"); SqlCommand cmd = new SqlCommand("select * from mudiamINC", con); cmd.Connection = con; con.Open(); } protected void Button1_Click(object sender, EventArgs e) { SqlConnection con = new SqlConnection("user id=sa;password=vikram;database=MUDIAM_INC"); SqlDataAdapter da = new SqlDataAdapter("select * from mudiamINC where fname like" + TextBox1.Text + " %", con); DataSet ds = new DataSet(); da.Fill(ds, "mudiamINC"); con.Open(); SqlCommand cmd = new SqlCommand(); cmd.Connection = con; cmd.CommandText = "select * from mudiamINC"; } }
Error Is:
ASP.NET Syntax (Toggle Plain Text)
An expression of non-boolean type specified in a context where a condition is expected, near 'likekrani'
please check the error and tell me the correct solution for that..
ASAP
another one is search information could be displayed in the browser in a tabular format.
please clarify my doubt.
please...please...please...please...please...please...please...please...
Last edited by peter_budo; Nov 28th, 2008 at 1:28 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: 538
Reputation:
Solved Threads: 86
I think the problem is where you're building your select
I'm think you need a space after the like, but not before the %
Note however that I suspect this code is 'bad form'. You are taking user input without validation and putting it into SQL queries. This potentially puts your application at risk for SQL injection attacks.
ASP.NET Syntax (Toggle Plain Text)
SqlDataAdapter da = new SqlDataAdapter("select * from mudiamINC where fname like" + TextBox1.Text + " %", con);
ASP.NET Syntax (Toggle Plain Text)
SqlDataAdapter da = new SqlDataAdapter("select * from mudiamINC where fname like " + TextBox1.Text + "%", con);
Note however that I suspect this code is 'bad form'. You are taking user input without validation and putting it into SQL queries. This potentially puts your application at risk for SQL injection attacks.
•
•
Join Date: May 2008
Posts: 538
Reputation:
Solved Threads: 86
I think for testing your example, you could ignore the 'bad form'.
But if this will be accessed by other people (especially the public) that might ever have malicious intent then you should address this and any other code that might be subject to attack.
For more information on protecting yourself from SQL Injection attacks, I recommend the following article:
http://msdn.microsoft.com/en-us/library/ms998271.aspx
But if this will be accessed by other people (especially the public) that might ever have malicious intent then you should address this and any other code that might be subject to attack.
For more information on protecting yourself from SQL Injection attacks, I recommend the following article:
http://msdn.microsoft.com/en-us/library/ms998271.aspx
![]() |
Similar Threads
- Search code in a database (Visual Basic 4 / 5 / 6)
- 'Object variable or With block variable not set' Error (ASP.NET)
- Visual C++ error LNK2022: metadata operation failed (80131187) (C++)
- Error while executing (Java)
- binary search (C++)
- Help with error checking code (C++)
- Error Linking KeyLogger.exe (C++)
Other Threads in the ASP.NET Forum
- Previous Thread: I'm new and need help and advice!
- Next Thread: Creating .EXE File
| Thread Tools | Search this Thread |
.net activexcontrol advice ajax alltypeofvideos appliances asp asp.net bc30451 beginner bottomasp.net box browser button c# cac checkbox click commonfunctions control css dataaccesslayer database datagridview datagridviewcheckbox datalist deadlock deployment development dgv dialog dropdownlist dynamic dynamically edit embeddingactivexcontrol expose fileuploader fill findcontrol flash formatdecimal formview gridview gudi iframe iis javascript listbox login microsoft mono mouse mssql multistepregistration news novell numerical objects opera panelmasterpagebuttoncontrols radio redirect registration relationaldatabases reportemail rotatepage save schoolproject search security sessionvariables silverlight smartcard smoobjects software sql-server sqlserver2005 ssl suse textbox tracking treeview unauthorized validatedate validation vb.net video videos virtualdirectory vista visualstudio web webapplications webdevelopemnt webdevelopment webprogramming webservice xsl youareanotmemberofthedebuggerusers





