Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > ADO.NET
|
ADO.NET For discussion about ADO.NET.  Topics such as question regarding the System.Data namespace are appropriate.  Questions specific to a particular application should be posted in a forum specific to the application .
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ADO.NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 10th, 2004, 10:28 AM
Friend of Wrox
 
Join Date: May 2004
Posts: 120
Thanks: 0
Thanked 1 Time in 1 Post
Default Error in issuing Parameterized Command

hi i am encountered such error like this in the below code
 strSql="select * from member where username=N'@username and password=N'@password";//
                    SqlDataAdapter objCommand=new SqlDataAdapter(strSql,objConnection);
                   objCommand.SelectCommand.Parameters.Add(new SqlParameter("@username",SqlDbType.NVarChar,50));//.Value=username.Text;
                   objCommand.SelectCommand.Parameters["@username"].Value="ali";//username.Text;
                   objCommand.SelectCommand.Parameters.Add(new SqlParameter("@password",SqlDbType.NVarChar,50));
                   objCommand.SelectCommand.Parameters["@password"].Value="12";//password.Text;
DataSet ds=new DataSet();
objCommand.Fill(ds,"member_info");
the error message is such thisSystem.Data.SqlClient.SqlException: Line 1: Incorrect syntax near '@password'. at System.Data.SqlClient.SqlCommand.ExecuteReader(Com mandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream) at System.Data.SqlClient.SqlCommand.ExecuteReader(Com mandBehavior behavior) at System.Data.SqlClient.SqlCommand.System.Data.IDbCo mmand.ExecuteReader(CommandBehavior behavior) at System.Data.Common.DbDataAdapter.FillFromCommand(O bject data, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable) .....
any one help me to do it
regards:)

__________________
       YoOrD .
Beauty is not on the face
Beauty is on the heart
~~<<Ghibran Khalil>>~~
 
Old June 15th, 2004, 06:22 PM
Registered User
 
Join Date: Aug 2003
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Try to use strSql=="select * from member where username=@username and password=@password";//
instead of
strSql=="select * from member where username=N'@username and password=N'@password";//

hope this solve ur problem.


Noman





Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell command execution error toshesh VB Databases Basics 3 January 7th, 2006 03:17 AM
Help! 'Command object error' sisi Classic ASP Databases 4 May 25th, 2004 06:23 PM
'bad command or file name' error freddie2165 JSP Basics 6 April 16th, 2004 06:58 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.