|
-
Sep 8th, 2007, 05:26 PM
#1
Thread Starter
Member
What is wrong with this?
Code:
Dim con As New ADODB.Connection
Dim con_string As String
Dim sql As String
Dim rs As New ADODB.Recordset
con_string = "Provider = Microsoft.Jet.OLEDB.4.0; Data Source = C:\Documents and Settings\leightr\My Documents\culverflex.mdb;"
con.Open(con_string)
sql = "delete * from whoishere where userid = " & ComboBox1.Text & ""
rs = con.Execute(sql)
I get a Data Mismatch error on: rs = con.Execute(sql)
Last edited by mousewonders; Sep 8th, 2007 at 07:29 PM.
-
Sep 8th, 2007, 05:32 PM
#2
Re: What is wrong with this?
Remove the * from the below line.
vb Code:
sql = "delete * from whoishere where userid = " & ComboBox1.Text & ""
-
Sep 8th, 2007, 05:35 PM
#3
Thread Starter
Member
Re: What is wrong with this?
Still a Data Mismatch error
-
Sep 8th, 2007, 05:41 PM
#4
Re: What is wrong with this?
shouldn't that be
"delete from whoishere where userid = '" & ComboBox1.text & "'"
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Sep 8th, 2007, 05:43 PM
#5
Thread Starter
Member
Re: What is wrong with this?
Yep Thanks a million!!
Any clue how to move the record to another table before I delete it?
-
Sep 8th, 2007, 05:57 PM
#6
Re: What is wrong with this?
you should be able to do something like this, but i haven't tried it at all
vb Code:
"insert into othertable (select * from whoishere whereuserid = '" & ComboBox1.text & "'")"
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Sep 8th, 2007, 06:08 PM
#7
Thread Starter
Member
Re: What is wrong with this?
It doesnt seem to work
Code:
Dim con As New ADODB.Connection
Dim con_string As String
Dim sql As String
Dim sql1 As String
Dim rs As New ADODB.Recordset
con_string = "Provider = Microsoft.Jet.OLEDB.4.0; Data Source = C:\Documents and Settings\leightr\My Documents\culverflex.mdb;"
con.Open(con_string)
sql1 = "insert into archive (select * from whoishere whereuserid = '" & ComboBox1.text & "'")"
sql = "delete from whoishere where userid = '" & TextBox1.Text & "'"
rs = con.Execute(sql)
-
Sep 8th, 2007, 06:55 PM
#8
Thread Starter
Member
Re: What is wrong with this?
Okay I got it working with the following... the only problem is now the delete will now work!! But if I remove the move sql the delete will work.
Code:
Dim con As New ADODB.Connection
Dim con_string As String
Dim move As String
Dim Sql As String
Dim rs As New ADODB.Recordset
con_string = "Provider = Microsoft.Jet.OLEDB.4.0; Data Source = C:\Documents and Settings\leightr\My Documents\culverflex.mdb;"
con.Open(con_string)
move = "INSERT INTO archive SELECT * FROM Whoishere WHERE userid = '" & TextBox1.Text & "'"
Sql = "delete from whoishere where userid = '" & TextBox1.Text & "'"
rs = con.Execute(move, Sql)
-
Sep 8th, 2007, 07:27 PM
#9
Thread Starter
Member
Re: What is wrong with this?
Okay.. I figured it out (again) I am not sure if this is the correct way of doing what I am doing.. but it works! I thought I would post the correct code.. maybe someone can re-write it the correct way?
Code:
Dim con As New ADODB.Connection
Dim con_string As String
Dim move As String
Dim del As String
Dim rs As New ADODB.Recordset
Dim rss As New ADODB.Recordset
con_string = "Provider = Microsoft.Jet.OLEDB.4.0; Data Source = C:\Documents and Settings\leightr\My Documents\culverflex.mdb;"
con.Open(con_string)
move = "INSERT INTO archive SELECT * FROM whoishere WHERE userid = '" & TextBox.Text & "'"
del = "DELETE * FROM whoishere WHERE userid = '" & TextBox.Text & "'"
rs = con.Execute(move)
del = "DELETE * FROM whoishere WHERE userid = '" & TextBox.Text & "'"
rss = con.Execute(del)
-
Sep 8th, 2007, 08:23 PM
#10
Re: What is wrong with this?
move = "INSERT INTO archive SELECT * FROM whoishere WHERE userid = '" & TextBox.Text & "'"
del = "DELETE * FROM whoishere WHERE userid = '" & TextBox.Text & "'"
rs = con.Execute(move)
del = "DELETE * FROM whoishere WHERE userid = '" & TextBox.Text & "'"
rss = con.Execute(del)
you don't need the del = twice,other than that looks ok
as it works, all is good
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Sep 9th, 2007, 08:47 AM
#11
Thread Starter
Member
Re: What is wrong with this?
lol. Opps I guess I forgot to remove the first del
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
|