Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4614766
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:44:46+00:00 2026-05-22T01:44:46+00:00

Im completely stumped. I’ve looked here: http://www.connectionstrings.com/excel-2007 . Changed my connectionstring appropriately. My dataset

  • 0

I”m completely stumped. I’ve looked here: http://www.connectionstrings.com/excel-2007. Changed my connectionstring appropriately. My dataset is fills with data. The Excel file already exists, but has nothing but a Header row. I can’t understand why the dataset can’t push the values to Excel. The only thing it’s doing is inserting a bunch of rows. There’s nothing so far indicates something is wrong. After two days of banging my head against this, I’ve come for your sage advice.

Protected Sub loadResxToExcel()

    Dim connString As String = ConfigurationManager.ConnectionStrings("xlsx").ConnectionString
    Dim oledbConn As OleDbConnection = New OleDbConnection(connString)

    Dim cmd As OleDbCommand = New OleDbCommand("SELECT * FROM [Sheet1$]", oledbConn)
    Dim updCmd As OleDbCommand = New OleDbCommand("UPDATE [Sheet1$] SET [Control] = @updCtrl, [Text] = @updText, [Comment] = @updCmnt, [English - en-US] = @updEngl, [Spanish - es-MX] = @updSpnh, [German - de] = @updGemn WHERE [ID] = @oldID", oledbConn)
    Dim insCmd As OleDbCommand = New OleDbCommand("INSERT INTO [Sheet1$] ([ID], [Control], [Text], [Comment], [English - en-US], [Spanish - es-MX], [German - de]) VALUES (@id, @ctrl, @text, @cmnt, @engl, @spnh, @gemn)", oledbConn)

    Dim updParamArray As OleDbParameter() = { _
                                                New OleDbParameter("@updID", OleDbType.LongVarChar), _
                                                New OleDbParameter("@updctrl", OleDbType.LongVarChar), _
                                                New OleDbParameter("@updText", OleDbType.LongVarChar), _
                                                New OleDbParameter("@updCmnt", OleDbType.LongVarChar), _
                                                New OleDbParameter("@updEngl", OleDbType.LongVarChar), _
                                                New OleDbParameter("@updSpnh", OleDbType.LongVarChar), _
                                                New OleDbParameter("@updGemn", OleDbType.LongVarChar) _
                                            }

    Dim insParamArray As OleDbParameter() = { _
                                                New OleDbParameter("@id", OleDbType.LongVarChar), _
                                                New OleDbParameter("@ctrl", OleDbType.LongVarChar), _
                                                New OleDbParameter("@text", OleDbType.LongVarChar), _
                                                New OleDbParameter("@cmnt", OleDbType.LongVarChar), _
                                                New OleDbParameter("@engl", OleDbType.LongVarChar), _
                                                New OleDbParameter("@spnh", OleDbType.LongVarChar), _
                                                New OleDbParameter("@gemn", OleDbType.LongVarChar) _
                                            }

    For Each oleParam As OleDbParameter In insParamArray

        oleParam.Value = ""
    Next


    For Each oleParam As OleDbParameter In updParamArray

        oleParam.Value = ""
    Next

    insCmd.Parameters.AddRange(insParamArray)
    updCmd.Parameters.AddRange(updParamArray)


    Dim oleda As OleDbDataAdapter = New OleDbDataAdapter()

    oleda.SelectCommand = cmd
    oleda.InsertCommand = insCmd
    oleda.UpdateCommand = updCmd

    Dim ds As DataSet = New DataSet()

    Try

        If Not xmlOriginFile Is Nothing Then

            Dim fileNav As XPathNavigator = xmlOriginFile.CreateNavigator()
            Dim fileItr As XPathNodeIterator = fileNav.Select("//data")
            Dim childNav As XPathNavigator

            ' Open connection
            oledbConn.Open()

            oleda.Fill(ds)
            ds.Tables(0).TableName = "Sheet1$"

            Dim pKeys(1) As DataColumn
            pKeys(0) = ds.Tables(0).Columns("ID")
            ds.Tables(0).PrimaryKey = pKeys
            Dim idnum As Integer = 1


            While (fileItr.MoveNext())

                Dim showCtrlName As String = fileItr.Current.GetAttribute("name", "")
                Dim showDesc As String = String.Empty
                Dim showLineNum As String = String.Empty


                If fileItr.Current.HasChildren() Then

                    childNav = fileItr.Current

                    If childNav.MoveToChild("value", "") Then
                        showDesc = childNav.Value
                    End If

                    If childNav.MoveToNext("comment", "") Then
                        showLineNum = childNav.Value
                    End If
                End If

                Dim addRow As DataRow = ds.Tables(0).NewRow()

                addRow.ItemArray() = New Object() {idnum, showCtrlName, showDesc, showLineNum, showDesc, String.Empty, String.Empty}

                ds.Tables(0).Rows.Add(addRow)

                idnum += 1
            End While 'loop thru nodes

            oleda.Update(ds, "Sheet1$")
        End If

    Catch ex As Exception

    Finally
        ' Close connection
        oledbConn.Close()
    End Try
End Sub

<connectionStrings>
        <add name="xls" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Sample1.xls;Extended Properties=Excel 8.0"/>
        <add name="xlsx" connectionString="Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Documents and Settings\cgramont\My Documents\Visual Studio 2008\WebSites\ResourceChanges\TU1371_v12.xlsx;Extended Properties='Excel 12.0 Xml;HDR=YES;'"/>
    </connectionStrings>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T01:44:46+00:00Added an answer on May 22, 2026 at 1:44 am

    What I did to finally get this to work.

    1. Change the OleDbParameter of “ID” from a LongVarChar to Integer
    2. Added size and sourceColumn to all parameters
    3. Commented out the assignments to values

    Afterwards, it all seemed to work. Code changes:

    Dim updParamArray As OleDbParameter() = { _
                                                New OleDbParameter("@updID", OleDbType.Integer, 32, "ID"), _
                                                New OleDbParameter("@updctrl", OleDbType.LongVarChar, 32, "Control"), _
                                                New OleDbParameter("@updText", OleDbType.LongVarChar, 256, "Text"), _
                                                New OleDbParameter("@updCmnt", OleDbType.LongVarChar, 32, "Comment"), _
                                                New OleDbParameter("@updEngl", OleDbType.LongVarChar, 256, "English - en-US"), _
                                                New OleDbParameter("@updSpnh", OleDbType.LongVarChar, 256, "Spanish - es-MX"), _
                                                New OleDbParameter("@updGemn", OleDbType.LongVarChar, 256, "German - de") _
                                            }
    
    Dim insParamArray As OleDbParameter() = { _
                                                New OleDbParameter("@id", OleDbType.Integer, 32, "ID"), _
                                                New OleDbParameter("@ctrl", OleDbType.LongVarChar, 32, "Control"), _
                                                New OleDbParameter("@text", OleDbType.LongVarChar, 256, "Text"), _
                                                New OleDbParameter("@cmnt", OleDbType.LongVarChar, 32, "Comment"), _
                                                New OleDbParameter("@engl", OleDbType.LongVarChar, 256, "English - en-US"), _
                                                New OleDbParameter("@spnh", OleDbType.LongVarChar, 256, "Spanish - es-MX"), _
                                                New OleDbParameter("@gemn", OleDbType.LongVarChar, 256, "German - de") _
                                            }
    
    'insParamArray(0).Value = 0
    'For i As Integer = 1 To (insParamArray.Length - 1)
    
    '    insParamArray(i).Value = ""
    'Next
    
    'updParamArray(0).Value = 0
    'For i As Integer = 1 To (updParamArray.Length - 1)
    
    '    updParamArray(i).Value = ""
    'Next
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.