Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. select with where clause in Sqlserver2000

select with where clause in Sqlserver2000

Scheduled Pinned Locked Moved C#
databasesysadminhelp
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    cishi_us
    wrote on last edited by
    #1

    i am connecting with sqlserver database ,then i need to acces that user which is in my textbox ,but no user comming from it. code is as follows: sqlConnString="server= your server; database= ;user id=;password=;"; sqlConn = new SqlConnection(sqlConnString); sqlConn.Open(); sqlCmd = new SqlCommand(“select username,password from table where username=@textbox1.text”); sqlDataAdapter da = new SqlDataAdapter(); da= cmd.executeReader() If da.read() { responser.redirect(“loginsuccess.aspx”) } else { response.write(“invalid login.aspx”) } +++++++++++++++++++++++++++ error is this System.Data.SqlClient.SqlException: Must declare the variable '@TextBox1'. at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream) at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior) at System.Data.SqlClient.SqlCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior) at System.Data.Common.DbDataAdapter.FillFromCommand(Object 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) at ASP.UserInfo_aspx.Page_Load()

    M 1 Reply Last reply
    0
    • C cishi_us

      i am connecting with sqlserver database ,then i need to acces that user which is in my textbox ,but no user comming from it. code is as follows: sqlConnString="server= your server; database= ;user id=;password=;"; sqlConn = new SqlConnection(sqlConnString); sqlConn.Open(); sqlCmd = new SqlCommand(“select username,password from table where username=@textbox1.text”); sqlDataAdapter da = new SqlDataAdapter(); da= cmd.executeReader() If da.read() { responser.redirect(“loginsuccess.aspx”) } else { response.write(“invalid login.aspx”) } +++++++++++++++++++++++++++ error is this System.Data.SqlClient.SqlException: Must declare the variable '@TextBox1'. at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream) at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior) at System.Data.SqlClient.SqlCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior) at System.Data.Common.DbDataAdapter.FillFromCommand(Object 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) at ASP.UserInfo_aspx.Page_Load()

      M Offline
      M Offline
      Marc Clifton
      wrote on last edited by
      #2

      cishi_us wrote: Must declare the variable '@TextBox1' Read up on how to use the SqlParameter object. Also, just use "@TextBox1", not "@TextBox1.Text". Marc MyXaml Advanced Unit Testing YAPO

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups