Hi all . i am using the folowing code to insert listview rows to mysql database. The table in my datbase has the following structure:
could any one show me how to make sure no duplicate rows(data) on proxy columnget inserted.(in another word i don't want dulicate proxy column values get insereted to table). Basicaly i want query the database if the data exist .If it exist already on the database then don't insert it and tell that user in massage box that data already exist .(and show the the succesfull insert rows in a textbox)I be happy if you guys show me how i can do such check or show me if there any better way to avoid duplicates.Thanks
sample data :
Code:
CREATE TABLE `test` (
`ID` int(11) NOT NULL auto_increment,
`proxy` varchar(93) NOT NULL default '0',
`port` varchar(93) NOT NULL default '0',
`proxyport` varchar(93) NOT NULL default '0',
PRIMARY KEY (`ID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=299 ;
could any one show me how to make sure no duplicate rows(data) on proxy columnget inserted.(in another word i don't want dulicate proxy column values get insereted to table). Basicaly i want query the database if the data exist .If it exist already on the database then don't insert it and tell that user in massage box that data already exist .(and show the the succesfull insert rows in a textbox)I be happy if you guys show me how i can do such check or show me if there any better way to avoid duplicates.Thanks
sample data :
Code:
[B]proxy-------------port------- proxyport[/B]
35.2.133.111 55252 35.2.133.111:55252
Code:
Private Sub Command6_Click()
Dim CNN As ADODB.Connection
Set CNN = New ADODB.Connection
CNN.Open "DRIVER={MySQL ODBC 3.51 Driver};SERVER=localhost;DATABASE=test;USER=root;PASSWORD=;OPTION=3;"
Dim sSQL As String
Dim i As Long
Dim meaw As String ' i added
For i = 1 To myListView.ListItems.Count
meaw = myListView.ListItems.item(i).Text & ":" & myListView.ListItems.item(i).SubItems(2)
'MsgBox meaw
CNN.Execute "INSERT INTO test (proxy,port,proxyport) VALUES('" & myListView.ListItems.item(i).Text & "','" & myListView.ListItems.item(i).SubItems(2) & "','" & meaw & "')"
'MsgBox sSQL
Next
MsgBox " finished"
End Sub