|
-
Jun 1st, 2002, 12:11 PM
#1
Thread Starter
Junior Member
SQL Insert Into Doesn't Insert Any Data
I have couple of problems. I am creating a MP3 player that scans the HD for MP3's and puts them into an Access database (XP, hope this doesn't make a difference). Anyway, I can use this method below to get the data into the database:
Data2.Recordset.AddNew
Data2.Recordset.Fields("Artist") = Trim(T1)
Data2.Recordset.Update
Data3.Recordset.AddNew
Data3.Recordset.Fields("Artist") = Trim(T1)
Data3.Recordset.Fields("Album") = Trim(T2)
Data3.Recordset.Update
Data1.Recordset.AddNew
Data1.Recordset.Fields("Artist") = Trim(T1)
Data1.Recordset.Fields("Album") = Trim(T2)
Data1.Recordset.Fields("Title") = Trim(T3)
Data1.Recordset.Fields("Genre") = Genre
Data1.Recordset.Fields("Year") = Year
Data1.Recordset.Fields("AudioLink") = T4
Data1.Recordset.Update
And it will actually get the data into the tables and fields that I need exactly. But my problem with this is I read the records in thru SQL:
strSQL1 = "SELECT [Album].* FROM [Album] WHERE Artist= '" & T1_A & "' ORDER BY [Album].[Album]"
Set RS = DB.OpenRecordset(strSQL1, dbOpenDynaset)
Set Data2.Recordset = RS
But when I select a record, it will give me a run-time error 3075. If I comment out the "Set" commands and put in say a MsgBox (strSQL1) instead, it will display the following:
SELECT [Album].* FROM [Album] WHERE Artist='Britney Spears
And nothing else after the name. It should have a ' ORDER BY [Album].[Album] following, but not matter what I try it won't.
If I go into the database and retype the exact same information on top of what was there, it will then work fine, example, if the recordset adds the record "Britney Spears" to the database with the code at the top, and I retype it, it will then work perfectly.
So instead of using the recordset methods, I decided to try and use the SQL Insert Into command:
sqlSTR5 = "INSERT INTO [Artist] (Artist) VALUES ('[" & Replace(T1, "'", "''") & Chr(34) & "]')"
sqlSTR6 = "INSERT INTO [Album] (Artist, Album) VALUES ('[" & Replace(T1, "'", "''") & "]','[" & Replace(T2, "'", "''") & "]')"
sqlSTR7 = "INSERT INTO [Main] (Artist, Album, Title, AudioLink) VALUES ('" & Replace(T1, "'", "''") & "', '" & Replace(T2, "'", "''") & "', '" & Replace(T3, "'", "''") & "', '" & Replace(T4, "'", "''") & "')"
Data2.Database.Execute sqlSTR5
Data2.Refresh
Data3.Database.Execute sqlSTR6
Data3.Refresh
Data1.Database.Execute sqlSTR7
Data1.Refresh
But the problem I get with this is that it searches through all the records, but when I look at the actual database, nothing is in it at all, for any table or records.
Any help would be greatly appreciated!!!!
Thanks, Corey
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|