Inserting HashTable Values into Database

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bharathiyerc
    New Member
    • Feb 2008
    • 2

    Inserting HashTable Values into Database

    I have created a stored procedure for insert

    CREATE PROCEDURE dbo.insert_samp le(@Name varchar(50),@Ag e char(4),@City varchar(50))
    AS
    INSERT dbo.Test1 VALUES(@Name,@A ge,@City)

    I want to create an HashTable, and insert Hashtable values to table......

    waiting for answers
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    I would think a DataTable object would be better suited then a hashtable, but you're free to use whatever you want.
    Have you gone through this:

    Comment

    • bharathiyerc
      New Member
      • Feb 2008
      • 2

      #3
      I have been alloted an assignment, it goes as :

      1.Place 3 textboxes,for name, city & age

      2.Create an Class.cs, in that declare property to get & set values.
      3.Create instance of Class.cs in code behind and assign the textbox values to it.
      4.And insert the values in database using the instance from another class.cs (where i will place my insert command)

      I have finished the above 4.......Next

      5.create stored procedure and then create an hashtable, and concatenate the "Keyname" with i/p parameters inside an loop.....

      Can help me out for 5th point.......i know about Connection string and how to use it.......

      Comment

      • Plater
        Recognized Expert Expert
        • Apr 2007
        • 7872

        #4
        We're not supposed to do assignments.
        But I guess it sounds like for every record you are going to be inserting, read off the values from the hashtable (which seems silly since you can only get one record out of that nicely) and execute your stored procedure with those values.

        Comment

        Working...