Insert data to database using Excel VBA is not workingexcel sql server error: Invalid object nameExcel VBA...

Why is working on the same position for more than 15 years not a red flag?

Where was Karl Mordo in Infinity War?

Can a person refuse a presidential pardon?

Criticizing long fiction. How is it different from short?

What are these green text/line displays shown during the livestream of Crew Dragon's approach to dock with the ISS?

Why is commutativity optional in multiplication for rings?

Predict mars robot position

For Loop and Sum

Why do neural networks need so many training examples to perform?

Is there a way to help users from having to clicking emails twice before logging into a new sandbox

What is Crew Dragon approaching in this picture?

If I delete my router's history can my ISP still provide it to my parents?

It took me a lot of time to make this, pls like. (YouTube Comments #1)

When does coming up with an idea constitute sufficient contribution for authorship?

What's a good word to describe a public place that looks like it wouldn't be rough?

Is the theory of the category of topological spaces computable?

Which aircraft had such a luxurious-looking navigator's station?

Dilemma of explaining to interviewer that he is the reason for declining second interview

Finding an integral using a table?

Quenching swords in dragon blood; why?

Do my Windows system binaries contain sensitive information?

On what did Lego base the appearance of the new Hogwarts minifigs?

Do authors have to be politically correct in article-writing?

Has the Isbell–Freyd criterion ever been used to check that a category is concretisable?



Insert data to database using Excel VBA is not working


excel sql server error: Invalid object nameExcel VBA row fetching loopFind duplicates, update database with minimum value in ExcelExcel VBA Code to move data from 4 specific cells to another worksheet in the next available rowExtract a worksheet from Excel retaining data values not referencesI'm looking to insert multiple itemized objects in excel via a VBATroubleshooting - How to mirror two cells from different sheets in Excel (2013) using VBAInsert data in a sheet based on data in other sheetExcel VBA - Copy cell values *without* data validationData is not copied in the same row (multiple workbooks to master sheet)













0















I have a macro that will upload data from multiple workbooks to the database. Table will differs based on what type of value/data being inserted. I have there tables. I can insert value in the first table just fine, but when it comes to second table, there's no value inserted, and im using the the exact same code as the first one but with different variables.



Set conn = CreateObject("ADODB.Connection")
Dim connection, insertData As String

connection = "Provider=; Database= Database; Integrated Security=SSPI;"

'open connection
conn.Open connection

insertData = "INSERT INTO Table2 ([Name], [AScore], [BScore], [CScore], [DScore], [EScore], [FScore]) " & _
" VALUES ('" & _
SummWb.Sheets("Sheet 2").Cells(13, "I").Value & "' , '" & _
SummWb.Sheets("Sheet 2").Cells(11, "J").Value & "' , '" & _
SummWb.Sheets("Sheet 2").Cells(6, "J").Value & "' , '" & _
SummWb.Sheets("Sheet 2").Cells(7, "J").Value & "' , '" & _
SummWb.Sheets("Sheet 2").Cells(3, "J").Value & "' , '" & _
SummWb.Sheets("Sheet 2").Cells(9, "J").Value & "' , '" & _
SummWb.Sheets("Sheet 2").Cells(10, "J").Value & "')"
conn.Execute insertData
conn.close


I've tried to see if my code is wrong, and I also tried to drop the table and create a new table, and also using a new workbook to test the code, but the result is still the same. Can you please help to see what is wrong with my code? I am using SQL Server Management Studio.









share



























    0















    I have a macro that will upload data from multiple workbooks to the database. Table will differs based on what type of value/data being inserted. I have there tables. I can insert value in the first table just fine, but when it comes to second table, there's no value inserted, and im using the the exact same code as the first one but with different variables.



    Set conn = CreateObject("ADODB.Connection")
    Dim connection, insertData As String

    connection = "Provider=; Database= Database; Integrated Security=SSPI;"

    'open connection
    conn.Open connection

    insertData = "INSERT INTO Table2 ([Name], [AScore], [BScore], [CScore], [DScore], [EScore], [FScore]) " & _
    " VALUES ('" & _
    SummWb.Sheets("Sheet 2").Cells(13, "I").Value & "' , '" & _
    SummWb.Sheets("Sheet 2").Cells(11, "J").Value & "' , '" & _
    SummWb.Sheets("Sheet 2").Cells(6, "J").Value & "' , '" & _
    SummWb.Sheets("Sheet 2").Cells(7, "J").Value & "' , '" & _
    SummWb.Sheets("Sheet 2").Cells(3, "J").Value & "' , '" & _
    SummWb.Sheets("Sheet 2").Cells(9, "J").Value & "' , '" & _
    SummWb.Sheets("Sheet 2").Cells(10, "J").Value & "')"
    conn.Execute insertData
    conn.close


    I've tried to see if my code is wrong, and I also tried to drop the table and create a new table, and also using a new workbook to test the code, but the result is still the same. Can you please help to see what is wrong with my code? I am using SQL Server Management Studio.









    share

























      0












      0








      0








      I have a macro that will upload data from multiple workbooks to the database. Table will differs based on what type of value/data being inserted. I have there tables. I can insert value in the first table just fine, but when it comes to second table, there's no value inserted, and im using the the exact same code as the first one but with different variables.



      Set conn = CreateObject("ADODB.Connection")
      Dim connection, insertData As String

      connection = "Provider=; Database= Database; Integrated Security=SSPI;"

      'open connection
      conn.Open connection

      insertData = "INSERT INTO Table2 ([Name], [AScore], [BScore], [CScore], [DScore], [EScore], [FScore]) " & _
      " VALUES ('" & _
      SummWb.Sheets("Sheet 2").Cells(13, "I").Value & "' , '" & _
      SummWb.Sheets("Sheet 2").Cells(11, "J").Value & "' , '" & _
      SummWb.Sheets("Sheet 2").Cells(6, "J").Value & "' , '" & _
      SummWb.Sheets("Sheet 2").Cells(7, "J").Value & "' , '" & _
      SummWb.Sheets("Sheet 2").Cells(3, "J").Value & "' , '" & _
      SummWb.Sheets("Sheet 2").Cells(9, "J").Value & "' , '" & _
      SummWb.Sheets("Sheet 2").Cells(10, "J").Value & "')"
      conn.Execute insertData
      conn.close


      I've tried to see if my code is wrong, and I also tried to drop the table and create a new table, and also using a new workbook to test the code, but the result is still the same. Can you please help to see what is wrong with my code? I am using SQL Server Management Studio.









      share














      I have a macro that will upload data from multiple workbooks to the database. Table will differs based on what type of value/data being inserted. I have there tables. I can insert value in the first table just fine, but when it comes to second table, there's no value inserted, and im using the the exact same code as the first one but with different variables.



      Set conn = CreateObject("ADODB.Connection")
      Dim connection, insertData As String

      connection = "Provider=; Database= Database; Integrated Security=SSPI;"

      'open connection
      conn.Open connection

      insertData = "INSERT INTO Table2 ([Name], [AScore], [BScore], [CScore], [DScore], [EScore], [FScore]) " & _
      " VALUES ('" & _
      SummWb.Sheets("Sheet 2").Cells(13, "I").Value & "' , '" & _
      SummWb.Sheets("Sheet 2").Cells(11, "J").Value & "' , '" & _
      SummWb.Sheets("Sheet 2").Cells(6, "J").Value & "' , '" & _
      SummWb.Sheets("Sheet 2").Cells(7, "J").Value & "' , '" & _
      SummWb.Sheets("Sheet 2").Cells(3, "J").Value & "' , '" & _
      SummWb.Sheets("Sheet 2").Cells(9, "J").Value & "' , '" & _
      SummWb.Sheets("Sheet 2").Cells(10, "J").Value & "')"
      conn.Execute insertData
      conn.close


      I've tried to see if my code is wrong, and I also tried to drop the table and create a new table, and also using a new workbook to test the code, but the result is still the same. Can you please help to see what is wrong with my code? I am using SQL Server Management Studio.







      microsoft-excel vba sql-server sql





      share












      share










      share



      share










      asked 3 mins ago









      user10236952user10236952

      31




      31






















          0






          active

          oldest

          votes











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "3"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1411058%2finsert-data-to-database-using-excel-vba-is-not-working%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Super User!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1411058%2finsert-data-to-database-using-excel-vba-is-not-working%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          VNC viewer RFB protocol error: bad desktop size 0x0I Cannot Type the Key 'd' (lowercase) in VNC Viewer...

          Tribunal Administrativo e Fiscal de Mirandela Referências Menu de...

          Couldn't open a raw socket. Error: Permission denied (13) (nmap)Is it possible to run networking commands...