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. how to add class in asp.net code

how to add class in asp.net code

Scheduled Pinned Locked Moved ASP.NET
csharptutorialasp-netdatabaseannouncement
3 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.
  • R Offline
    R Offline
    ramyasangeet
    wrote on last edited by
    #1

    hi all, i am creating a page in asp.net using c#.To insert the data,i just wrote the sql command for inserting and followed the same for edit and update. for example.. string myinsertQuery = "insert into DriveUnits(SerialNumber,CorporationID,CorporationDivisionID,HWVersion,DateManufactured) values('" + SrNumber_TBox.Text + "','" + Session["corporationid"] + "','" + CorporationDivisionID + "','" + Hwversion_Tbox.Text + "','" + DateMFD_TBox.Text + "')"; SqlCommand myCommand_insert = new SqlCommand(myinsertQuery); myCommand_insert.Connection = myConnection; myCommand_insert.ExecuteNonQuery(); myCommand_insert.Connection.Close(); but instead of writing code in cs file,i just want to call a class so that wherever we need to insert data,we can just call the class and the functions defined. i created a class and a function and pass parameters.but it is showin invalid arguments.. plz give ur suggestions on creating a class and its functions. Thanks in advance,

    cheers sangeet

    M C 2 Replies Last reply
    0
    • R ramyasangeet

      hi all, i am creating a page in asp.net using c#.To insert the data,i just wrote the sql command for inserting and followed the same for edit and update. for example.. string myinsertQuery = "insert into DriveUnits(SerialNumber,CorporationID,CorporationDivisionID,HWVersion,DateManufactured) values('" + SrNumber_TBox.Text + "','" + Session["corporationid"] + "','" + CorporationDivisionID + "','" + Hwversion_Tbox.Text + "','" + DateMFD_TBox.Text + "')"; SqlCommand myCommand_insert = new SqlCommand(myinsertQuery); myCommand_insert.Connection = myConnection; myCommand_insert.ExecuteNonQuery(); myCommand_insert.Connection.Close(); but instead of writing code in cs file,i just want to call a class so that wherever we need to insert data,we can just call the class and the functions defined. i created a class and a function and pass parameters.but it is showin invalid arguments.. plz give ur suggestions on creating a class and its functions. Thanks in advance,

      cheers sangeet

      M Offline
      M Offline
      Michael Sync
      wrote on last edited by
      #2

      not sure i got you.. maybe this is what you want.. Using static method.

      public class MyDBMgmt{
      public static bool ExecuteSQL(string cmdText)
      {
      return true;
      }
      }

      Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net) If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read here. Thank you. :)

      1 Reply Last reply
      0
      • R ramyasangeet

        hi all, i am creating a page in asp.net using c#.To insert the data,i just wrote the sql command for inserting and followed the same for edit and update. for example.. string myinsertQuery = "insert into DriveUnits(SerialNumber,CorporationID,CorporationDivisionID,HWVersion,DateManufactured) values('" + SrNumber_TBox.Text + "','" + Session["corporationid"] + "','" + CorporationDivisionID + "','" + Hwversion_Tbox.Text + "','" + DateMFD_TBox.Text + "')"; SqlCommand myCommand_insert = new SqlCommand(myinsertQuery); myCommand_insert.Connection = myConnection; myCommand_insert.ExecuteNonQuery(); myCommand_insert.Connection.Close(); but instead of writing code in cs file,i just want to call a class so that wherever we need to insert data,we can just call the class and the functions defined. i created a class and a function and pass parameters.but it is showin invalid arguments.. plz give ur suggestions on creating a class and its functions. Thanks in advance,

        cheers sangeet

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

        Is this ASP.NET 1.0, 1.1, or 2.0 ? What errors are you getting ? You should certainly put all your SQL in a class, so that it's in a seperate layer to the rest of your app, and can be reused as needed.

        Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

        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