Advertisement

04.01.2005 at 09:25AM PST, ID: 21373131
[x]
Attachment Details

INSERT Statement won't work

Asked by delta-mp in Microsoft Access Database

Tags: insert, access, statement

Working with an Access database in ADO.NET (using ASP.NET)

 Dim strSQL As String
        Dim strSearchFor As String
        Dim arrWords As String()
        Dim arrWord As String
        Dim RecordCount As Integer
        Dim dcJMS As New OleDb.OleDbCommand
        strSearchFor = Request("txtClient")
        arrWords = (strSearchFor.Split(" "))
        'cnJMS.Open()
        'dcJMS.CommandText = "DELETE * FROM ClientSearch WHERE UserID=" & Session("UserID")
        'dcJMS.ExecuteScalar()
        'cnJMS.Close()
        'RecordCount = dcJMS.ExecuteNonQuery()

        For Each arrWord In arrWords

            dcJMS.CommandText = "INSERT INTO ClientSearch SELECT CLID As ClientID, '" & arrWord & "' AS Word, '" & strSearchFor & "' AS SearchedFor, " & Session("UserID") & " AS UserID FROM tblClientData WHERE Company like '*" & arrWord & "*'"
            dcJMS.Connection = cnJMS
            cnJMS.Open()
            dcJMS.ExecuteNonQuery()
            dcJMS.Connection.Close()
        Next

now this runs and doesn't cause any exceptions and appears to have worked fine but nothing gets inserted into the table.

This is some example data captured in my Autos
      dcJMS.CommandText      "INSERT INTO ClientSearch SELECT CLID As ClientID, 'test' AS Word, 'this is a test' AS SearchedFor, 1 AS UserID FROM tblClientData WHERE Company like '*test*'"      String
      arrWord      "test"      String
      strSearchFor      "this is a test"      String

If I run "SELECT CLID As ClientID, 'test' AS Word, 'this is a test' AS SearchedFor, 1 AS UserID FROM tblClientData WHERE Company like '*test*'" in a test query inside M$ Access it displays 11 records, why won't the INSERT INTO <> SELECT <> work

Your help is muchly apprecaited
Start Free Trial
[+][-]04.01.2005 at 09:39AM PST, ID: 13682690

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.01.2005 at 01:54PM PST, ID: 13684793

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Microsoft Access Database
Tags: insert, access, statement
Sign Up Now!
Solution Provided By: shanesuebsahakarn
Participating Experts: 2
Solution Grade: A
 
 
[+][-]04.03.2005 at 06:40PM PDT, ID: 13694361

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32