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. Web Development
  3. ASP.NET
  4. ADO.net

ADO.net

Scheduled Pinned Locked Moved ASP.NET
databasecsharpcomhelptutorial
13 Posts 3 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 chohanpk

    but i m following the tutorial.when i m using the executenonquery,it gives the "int " error as u said.and when i m using ExecuteReader before sqlparamerters,as in tutorial,it gives error"Procedure 'ShowSuppliers' expects parameter '@txt', which was not supplied." protected void Page_Load(object sender, EventArgs e) { SqlConnection con= new SqlConnection("Data Source=n-6e9a4f688df44;Initial Catalog=Northwind;Integrated Security=True"); con.Open(); SqlCommand com = new SqlCommand("ShowSuppliers", con); com.CommandType = CommandType.StoredProcedure; SqlDataReader reader = com.ExecuteReader(); SqlParameter parm = com.Parameters.Add("@txt", SqlDbType.VarChar, 50); parm.Direction = ParameterDirection.Input; parm.Value = "UK"; while (reader.Read()== true) { Response.Write(reader[0].ToString() + "
    "); } reader.Close(); con.Close(); } .and when i used ExecuteReader after sqlparameter it shows nothing on output protected void Page_Load(object sender, EventArgs e) { SqlConnection con= new SqlConnection("Data Source=n-6e9a4f688df44;Initial Catalog=Northwind;Integrated Security=True"); con.Open(); SqlCommand com = new SqlCommand("ShowSuppliers", con); com.CommandType = CommandType.StoredProcedure; SqlDataReader reader = com.ExecuteReader(); SqlParameter parm = com.Parameters.Add("@txt", SqlDbType.VarChar, 50); parm.Direction = ParameterDirection.Input; parm.Value = "UK"; //SqlDataReader reader = com.ExecuteNonQuery(); //SqlDataReader reader = com.ExecuteReader(); while (reader.Read()== true) { Response.Write(reader[0].ToString() + "
    "); } reader.Close(); con.Close(); } n for procedure i want to create a procedure then y its changed to Alter.i dont want edit any value. kindly check the tutorial.

    Chohan

    G Offline
    G Offline
    Guffa
    wrote on last edited by
    #4

    chohanpk wrote:

    but i m following the tutorial.

    That doesn't help the least bit when the tutorial is wrong.

    chohanpk wrote:

    when i m using ExecuteReader before sqlparamerters,as in tutorial,it gives error"Procedure 'ShowSuppliers' expects parameter '@txt', which was not supplied."

    You have to set the parameter berfore calling the procedure. The procedure can not use a parameter that you add in the future.

    chohanpk wrote:

    n for procedure i want to create a procedure then y its changed to Alter.i dont want edit any value.

    When you have created the procedure, it's displayed for you so that you can edit it. Even if you don't want to edit it, it's shown that way. To show it so that you could create it would be pointless, as you have already done that.

    --- Year happy = new Year(2007);

    C 1 Reply Last reply
    0
    • G Guffa

      chohanpk wrote:

      but i m following the tutorial.

      That doesn't help the least bit when the tutorial is wrong.

      chohanpk wrote:

      when i m using ExecuteReader before sqlparamerters,as in tutorial,it gives error"Procedure 'ShowSuppliers' expects parameter '@txt', which was not supplied."

      You have to set the parameter berfore calling the procedure. The procedure can not use a parameter that you add in the future.

      chohanpk wrote:

      n for procedure i want to create a procedure then y its changed to Alter.i dont want edit any value.

      When you have created the procedure, it's displayed for you so that you can edit it. Even if you don't want to edit it, it's shown that way. To show it so that you could create it would be pointless, as you have already done that.

      --- Year happy = new Year(2007);

      C Offline
      C Offline
      chohanpk
      wrote on last edited by
      #5

      i give parameter befor but now it didnt show anything .just open a blank page. protected void Page_Load(object sender, EventArgs e) { SqlConnection con= new SqlConnection("Data Source=n-6e9a4f688df44;Initial Catalog=Northwind;Integrated Security=True"); con.Open(); SqlCommand com = new SqlCommand("ShowSuppliers", con); com.CommandType = CommandType.StoredProcedure; //SqlDataReader reader = com.ExecuteReader(); SqlParameter parm = com.Parameters.Add("@txt", SqlDbType.VarChar, 50); parm.Direction = ParameterDirection.Input; parm.Value = "UK"; SqlDataReader reader = com.ExecuteReader(); while (reader.Read() == true) { Response.Write(reader[0].ToString() + "
      "); } reader.Close(); con.Close(); } will you plz tel me what will be the right code? and how can i do it using execute "ExecuteNonQuery", also code for this. thanks

      Chohan

      G 1 Reply Last reply
      0
      • C chohanpk

        i give parameter befor but now it didnt show anything .just open a blank page. protected void Page_Load(object sender, EventArgs e) { SqlConnection con= new SqlConnection("Data Source=n-6e9a4f688df44;Initial Catalog=Northwind;Integrated Security=True"); con.Open(); SqlCommand com = new SqlCommand("ShowSuppliers", con); com.CommandType = CommandType.StoredProcedure; //SqlDataReader reader = com.ExecuteReader(); SqlParameter parm = com.Parameters.Add("@txt", SqlDbType.VarChar, 50); parm.Direction = ParameterDirection.Input; parm.Value = "UK"; SqlDataReader reader = com.ExecuteReader(); while (reader.Read() == true) { Response.Write(reader[0].ToString() + "
        "); } reader.Close(); con.Close(); } will you plz tel me what will be the right code? and how can i do it using execute "ExecuteNonQuery", also code for this. thanks

        Chohan

        G Offline
        G Offline
        Guffa
        wrote on last edited by
        #6

        Do you have any suppliers in the database that matches the condition? Have you tried "view source" on the page? As you are using Response.Write, you will be writing out the data before the actual html code. That will break the html code so that it might not show, but the data will be visible in the source of the page.

        --- Year happy = new Year(2007);

        C 1 Reply Last reply
        0
        • G Guffa

          Do you have any suppliers in the database that matches the condition? Have you tried "view source" on the page? As you are using Response.Write, you will be writing out the data before the actual html code. That will break the html code so that it might not show, but the data will be visible in the source of the page.

          --- Year happy = new Year(2007);

          C Offline
          C Offline
          chohanpk
          wrote on last edited by
          #7

          sorry i didnt understand what u asked? as i m begginer in asp.net.

          Chohan

          G 1 Reply Last reply
          0
          • C chohanpk

            sorry i didnt understand what u asked? as i m begginer in asp.net.

            Chohan

            G Offline
            G Offline
            Guffa
            wrote on last edited by
            #8

            Exactly what was it that you didn't understand? If I have to explain everything assuming that you know absolutely nothing at all about it, it gets rather long...

            --- Year happy = new Year(2007);

            C 1 Reply Last reply
            0
            • G Guffa

              Exactly what was it that you didn't understand? If I have to explain everything assuming that you know absolutely nothing at all about it, it gets rather long...

              --- Year happy = new Year(2007);

              C Offline
              C Offline
              chohanpk
              wrote on last edited by
              #9

              tel me wats wrong in my code, give me right code

              Chohan

              C G 2 Replies Last reply
              0
              • C chohanpk

                tel me wats wrong in my code, give me right code

                Chohan

                C Offline
                C Offline
                Christian Graus
                wrote on last edited by
                #10

                chohanpk wrote:

                give me right code

                :laugh::laugh::laugh: It's not that easy. Without a copy of your database, he doesn't know what's wrong. He's told you how to work it out. If you can't work it out, abandon this project, work on something simpler, or at least buy a book and work through it.

                Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

                1 Reply Last reply
                0
                • C chohanpk

                  tel me wats wrong in my code, give me right code

                  Chohan

                  G Offline
                  G Offline
                  Guffa
                  wrote on last edited by
                  #11

                  chohanpk wrote:

                  tel me wats wrong in my code, give me right code

                  I don't see anything wrong in your code. Except of course using Response.Write, but I already explained about that.

                  --- Year happy = new Year(2007);

                  C 1 Reply Last reply
                  0
                  • G Guffa

                    chohanpk wrote:

                    tel me wats wrong in my code, give me right code

                    I don't see anything wrong in your code. Except of course using Response.Write, but I already explained about that.

                    --- Year happy = new Year(2007);

                    C Offline
                    C Offline
                    chohanpk
                    wrote on last edited by
                    #12

                    i m using the "northwind" database. n there are matching countries there like USA . and what is "view source" kindly tel me.

                    Chohan

                    G 1 Reply Last reply
                    0
                    • C chohanpk

                      i m using the "northwind" database. n there are matching countries there like USA . and what is "view source" kindly tel me.

                      Chohan

                      G Offline
                      G Offline
                      Guffa
                      wrote on last edited by
                      #13

                      chohanpk wrote:

                      and what is "view source" kindly tel me.

                      In the View menu in the browser you will find the option Source. That will show you the html code that was sent to the browser.

                      --- Year happy = new Year(2007);

                      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