Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Pro VB Databases
| Search | Today's Posts | Mark Forums Read
Pro VB Databases Advanced-level VB coding questions specific to using VB with databases. Beginning-level questions or issues not specific to database use will be redirected to other forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro VB Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 17th, 2006, 06:18 AM
Friend of Wrox
 
Join Date: Mar 2005
Location: , , .
Posts: 264
Thanks: 0
Thanked 0 Times in 0 Posts
Default problem writing listview data to mysql db

Hi all i have difficulty writing each row of listview to mysql db. I be happy if some one help me fix it.Thanks



Code:
Private Sub Command11_Click()
 Dim CNN As ADODB.Connection
Set CNN = New ADODB.Connection
CNN.Open "DRIVER={MySQL ODBC 3.51 Driver};SERVER=localhost;DATABASE=visualbasic6;USER=root;PASSWORD=;OPTION=3;"


 Dim sSQL As String
Dim i As Long
For i = 1 To ListView1.ListItems.Count
    sSQL = "INSERT INTO musictest (url,songname,artist,album) "
    sSQL = sSQL & " VALUES('" & ListView1.ListItems.Item(i).Text & "', '"
    sSQL = sSQL & " " & ListView1.Subitems(1) &Â Â ', '"
    sSQL = sSQL & " & ListView1.Subitems(2) &Â Â ', '"
    sSQL = sSQL & " & ListView1.Subitems(3) &Â Â ', '"

    MsgBox sSQL
    'etc
    CNN.Execute sSQL
Next
    Â Â 
MsgBox " The songs are inserted to database successfully"
End Sub
error pic
http://i5.photobucket.com/albums/y18...orlistview.jpg

and points to :CNN.Execute sSQL

i printed out the sql and the url field was used corectly but not the rest:
sql statment pic :
[IMG] http://i5.photobucket.com/albums/y18...7/sqlprint.jpg [/IMG]


I even tried this and got error:


Code:
sSQL = sSQL & " VALUES('" & ListView1.ListItems.Item(i).Text & "','" & ListView1.SubItems(1) & "','" & ListView1.SubItems(2) & "', '" & ListView1.SubItems(3) & "')"
Code:
Compile error:

Method or data member not found
pointing at :.SubItems

could u help me fix this.thanks




Similar Threads
Thread Thread Starter Forum Replies Last Post
Retrieve image data from mysql db vermaarun2005 PHP Databases 0 July 14th, 2007 11:12 AM
problem writing listview data to mysql db method Pro VB 6 2 April 10th, 2007 07:17 PM
Drawing Data from mysql DB to use on app majika MySQL 2 November 1st, 2006 09:27 AM
Writing to an msAccess db from txtBox Data sconineuk ADO.NET 0 March 8th, 2006 03:13 PM
problem with uploading blob data to MySQL DB kyle_shea PHP Databases 1 March 8th, 2005 06:15 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.