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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. System.Data.SqlClient.SqlException:

System.Data.SqlClient.SqlException:

Scheduled Pinned Locked Moved ASP.NET
csharpasp-nethelptutorial
5 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.
  • K Offline
    K Offline
    kal2na2
    wrote on last edited by
    #1

    :((hi System.Data.SqlClient.SqlException: Prepared statement '(@Start_Code nchar(3),@Start1_Code nchar(3))select ' expects parameter @Start1_Code, which was not supplied. I am getting such error in my project asp.net with code behind C#.net any idea how to resolve it kal2na2 -- modified at 6:12 Friday 2nd December, 2005

    C 1 Reply Last reply
    0
    • K kal2na2

      :((hi System.Data.SqlClient.SqlException: Prepared statement '(@Start_Code nchar(3),@Start1_Code nchar(3))select ' expects parameter @Start1_Code, which was not supplied. I am getting such error in my project asp.net with code behind C#.net any idea how to resolve it kal2na2 -- modified at 6:12 Friday 2nd December, 2005

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      kal2na2 wrote:

      System.Data.SqlClient.SqlException: Prepared statement '(@Start_Code nchar(3),@Start1_Code nchar(3))select ' expects parameter @Start1_Code, which was not supplied. I am getting such error in my project asp.net with code behind C#.net any idea how to resolve it

      Yes, the answer is to supply the appropriate parameters to the SqlCommand object as indicated by the exception message. You might like to post the code that creates and executes the SQL - it would make answering the question easier.


      My: Blog | Photos "Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucious

      K 1 Reply Last reply
      0
      • C Colin Angus Mackay

        kal2na2 wrote:

        System.Data.SqlClient.SqlException: Prepared statement '(@Start_Code nchar(3),@Start1_Code nchar(3))select ' expects parameter @Start1_Code, which was not supplied. I am getting such error in my project asp.net with code behind C#.net any idea how to resolve it

        Yes, the answer is to supply the appropriate parameters to the SqlCommand object as indicated by the exception message. You might like to post the code that creates and executes the SQL - it would make answering the question easier.


        My: Blog | Photos "Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucious

        K Offline
        K Offline
        kal2na2
        wrote on last edited by
        #3

        hi here i am posting my code lbs and lbd are listbox names sqlConnection1.Open(); string selectCommand="select Date,Start1_Code ,Start2_Code from Dates where Start1_Code='SMTP' and Start2_Code='SAD' Order By Date"; SqlDataAdapter myCommand=new SqlDataAdapter(selectCommand,sqlConnection2); myCommand.SelectCommand.Parameters.Add(new SqlParameter("@Start1_Code",SqlDbType.NChar,3)); myCommand.SelectCommand.Parameters["@Start1_Code"].Value=txtMsg.Text; ; myCommand.SelectCommand.Parameters.Add(new SqlParameter("@Start2_Code",SqlDbType.NChar,3)); myCommand.SelectCommand.Parameters["@Start2_Code"].Value =Start2_Station_Code; DataSet dataset=new DataSet(); myCommand.Fill(dataset,"Dates"); lbs.DataSource=dataset.Tables["Dates"].DefaultView; lbs.DataBind(); lbd.DataSource =dataset.Tables["Dates"].DefaultView; lbd.DataBind(); sqlConnection2.Close(); kal2na2

        C K 2 Replies Last reply
        0
        • K kal2na2

          hi here i am posting my code lbs and lbd are listbox names sqlConnection1.Open(); string selectCommand="select Date,Start1_Code ,Start2_Code from Dates where Start1_Code='SMTP' and Start2_Code='SAD' Order By Date"; SqlDataAdapter myCommand=new SqlDataAdapter(selectCommand,sqlConnection2); myCommand.SelectCommand.Parameters.Add(new SqlParameter("@Start1_Code",SqlDbType.NChar,3)); myCommand.SelectCommand.Parameters["@Start1_Code"].Value=txtMsg.Text; ; myCommand.SelectCommand.Parameters.Add(new SqlParameter("@Start2_Code",SqlDbType.NChar,3)); myCommand.SelectCommand.Parameters["@Start2_Code"].Value =Start2_Station_Code; DataSet dataset=new DataSet(); myCommand.Fill(dataset,"Dates"); lbs.DataSource=dataset.Tables["Dates"].DefaultView; lbs.DataBind(); lbd.DataSource =dataset.Tables["Dates"].DefaultView; lbd.DataBind(); sqlConnection2.Close(); kal2na2

          C Offline
          C Offline
          Colin Angus Mackay
          wrote on last edited by
          #4

          You are supplying parameters that are not being used. No where in your SQL Statement do you use @Start1_Code or @Start2_Code Did you mean your SQL Statement to be: SELECT Date, Start1_Code, Start2_Code FROM Dates WHERE Start1_Code=@Start1_Code and Start2_Code=@Start2_Code ORDER BY Date Also, you have stated that @Start1_Code is nchar(3), but in your SQL Statement you have 'SMTP' which is 4 characters. What is sqlConnection1? You open it, but it is never used.


          My: Blog | Photos "Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucious

          1 Reply Last reply
          0
          • K kal2na2

            hi here i am posting my code lbs and lbd are listbox names sqlConnection1.Open(); string selectCommand="select Date,Start1_Code ,Start2_Code from Dates where Start1_Code='SMTP' and Start2_Code='SAD' Order By Date"; SqlDataAdapter myCommand=new SqlDataAdapter(selectCommand,sqlConnection2); myCommand.SelectCommand.Parameters.Add(new SqlParameter("@Start1_Code",SqlDbType.NChar,3)); myCommand.SelectCommand.Parameters["@Start1_Code"].Value=txtMsg.Text; ; myCommand.SelectCommand.Parameters.Add(new SqlParameter("@Start2_Code",SqlDbType.NChar,3)); myCommand.SelectCommand.Parameters["@Start2_Code"].Value =Start2_Station_Code; DataSet dataset=new DataSet(); myCommand.Fill(dataset,"Dates"); lbs.DataSource=dataset.Tables["Dates"].DefaultView; lbs.DataBind(); lbd.DataSource =dataset.Tables["Dates"].DefaultView; lbd.DataBind(); sqlConnection2.Close(); kal2na2

            K Offline
            K Offline
            kal2na2
            wrote on last edited by
            #5

            hi its sqlConnection2.Open() not sqlConnection1.Open() string selectCommand="select Date,Start1_Code ,Start2_Code from Dates where Start1_Code='SMP' and Start2_Code='SAD' Order By Date"; but still same thing persits is something wong in my stored procedure kal2na2

            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