urgent-transferrring data from excel to sqlserver using webforms

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tanya2001
    New Member
    • Nov 2007
    • 23

    urgent-transferrring data from excel to sqlserver using webforms

    hi all
    can somebody plzz tell me how to transfer data from excel 2003 to sql server 2000 using webforms.

    I have a table in excel and i want to transfer the entire data into sqlserver table...how can i do it plzzz help me
  • mzmishra
    Recognized Expert Contributor
    • Aug 2007
    • 390

    #2
    This link will help you
    http://forums.asp.net/p/1132513/1821793.aspx

    Comment

    • dip_developer
      Recognized Expert Contributor
      • Aug 2006
      • 648

      #3
      Originally posted by tanya2001
      hi all
      can somebody plzz tell me how to transfer data from excel 2003 to sql server 2000 using webforms.

      I have a table in excel and i want to transfer the entire data into sqlserver table...how can i do it plzzz help me
      Fill a dataset with the excel records with the following code........... .now I think rest (inserting records into database from dataset)will be done easily

      [CODE=vbnet]
      Dim conStr As String = "provider=Micro soft.Jet.OLEDB. 4.0;data source=" + fileName + "; Extended Properties=Exce l 8.0;"
      Dim sql As String = "select * from [Sheet1$]" '-------- "Sheet1" is the name of the excel sheet
      MyConnection = New System.Data.Ole Db.OleDbConnect ion(connections tring)
      MyConnection.Op en()
      MyAdapter = New System.Data.Ole Db.OleDbDataAda pter(sql, MyConnection)
      Dim myDataSet As DataSet = New System.Data.Dat aSet
      MyAdapter.Fill( myDataSet)[/CODE]

      Comment

      • tanya2001
        New Member
        • Nov 2007
        • 23

        #4
        Originally posted by dip_developer
        Fill a dataset with the excel records with the following code........... .now I think rest (inserting records into database from dataset)will be done easily

        [CODE=vbnet]
        Dim conStr As String = "provider=Micro soft.Jet.OLEDB. 4.0;data source=" + fileName + "; Extended Properties=Exce l 8.0;"
        Dim sql As String = "select * from [Sheet1$]" '-------- "Sheet1" is the name of the excel sheet
        MyConnection = New System.Data.Ole Db.OleDbConnect ion(connections tring)
        MyConnection.Op en()
        MyAdapter = New System.Data.Ole Db.OleDbDataAda pter(sql, MyConnection)
        Dim myDataSet As DataSet = New System.Data.Dat aSet
        MyAdapter.Fill( myDataSet)[/CODE]

        hi can u plz elaborate the code more plzz coz m all new 2 .net so i dunno much abt it...so can u plz...my excel sheet name is sheet1 and sql table name is table5

        Comment

        • Shashi Sadasivan
          Recognized Expert Top Contributor
          • Aug 2007
          • 1435

          #5
          hi,
          the code given by dip_developer indicates pretty clearly that a dataset with the values of your excel file will be contained in it.
          now its upto you to transfer them to the sql server, because you are the best who knows about the schema of your database and the schema of the excel file

          Comment

          • tanya2001
            New Member
            • Nov 2007
            • 23

            #6
            Originally posted by Shashi Sadasivan
            hi,
            the code given by dip_developer indicates pretty clearly that a dataset with the values of your excel file will be contained in it.
            now its upto you to transfer them to the sql server, because you are the best who knows about the schema of your database and the schema of the excel file
            i wanted to know tht the below code shows the connection string for excel
            Dim conStr As String = "provider=Micro soft.Jet.OLEDB. 4.0;data source=" + fileName + "; Extended Properties=Exce l 8.0;"

            abd now here below agn asks for d same excel connection...wh ere do v have 2 give the sql connection string
            MyConnection = New System.Data.Ole Db.OleDbConnect ion(connections tring)

            Comment

            • dip_developer
              Recognized Expert Contributor
              • Aug 2006
              • 648

              #7
              Originally posted by tanya2001
              i wanted to know tht the below code shows the connection string for excel
              Dim conStr As String = "provider=Micro soft.Jet.OLEDB. 4.0;data source=" + fileName + "; Extended Properties=Exce l 8.0;"

              abd now here below agn asks for d same excel connection...wh ere do v have 2 give the sql connection string
              MyConnection = New System.Data.Ole Db.OleDbConnect ion(connections tring)
              extremely sorry friend......... the variable name connenctionstri ng would be conStr or vice versa....both are same........

              sorry for that mistake....I should be more watchful while replying....... .....

              Comment

              Working...