The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages - More
> Visual Basic Programming
|
PhpSQL/VB help with code
Discuss PhpSQL/VB help with code in the Visual Basic Programming forum on Dev Shed. PhpSQL/VB help with code Visual Basic Programming forum discussing VB specific programming information. Quickly prototype and build applications with this robust and simple language.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

November 21st, 2011, 07:19 AM
|
|
|
|
SQL/VB help with code
Hi, trying to update my phpsql database after this code:
Try
For Each itemChecked In Sykkel.clistterreng.CheckedItems
ListBoxvarer.Items.Add(quote + itemChecked.ToString() + quote)
conn.Open()
Dim sqlUpdate As New MySqlCommand("UPDATE Sykkel SET leidut = 1 WHERE CONCAT(sykkel_nr, ' ', sykkel_type) = '" & itemChecked & "'", conn)
Dim adapter As New MySqlDataAdapter
Dim tabell As New DataTable
adapter.SelectCommand = sqlUpdate
adapter.Fill(tabell)
conn.Close()
Dim rad As DataRow
Dim utleid As String
For Each rad In tabell.Rows
utleid = rad("leidut")
Next rad
Next
catch ex As Exception
MsgBox("Noe gikk feil git")
End Try
Can anyone see what's wrong here? If I change the sql sentence to:
Dim sqlUpdate As New MySqlCommand("UPDATE Sykkel SET leidut = 1", conn)
It works, but updates the whole table. When I try my sentence in the actual sql website (myphpadmin) that sentence with CONCAT works perfectly :S
EDIT:
I see that items.checked makes the string come out like this "a001 terrengsykkel", when i want it to just go: a001 terrengsykkel
The thing is, if i change the code to:
Dim sqlUpdate As New MySqlCommand("UPDATE Sykkel SET leidut = 1 WHERE CONCAT(sykkel_nr, ' ', sykkel_type) = itemChecked, conn)
It should work in theory, atelast the SQL sentence works, but I get an error in VB.
|

November 21st, 2011, 07:03 PM
|
|
|
|
What is a phpsql database? Never heard of it.
__________________
======
Doug G
======
It is a truism of American politics that no man who can win an election deserves to. --Trevanian, from the novel Shibumi
|

November 22nd, 2011, 03:14 AM
|
|
|
Quote: | Originally Posted by Doug G What is a phpsql database? Never heard of it. |
Haha sorry, SQL
|

November 22nd, 2011, 03:59 AM
|
|
|
|
Basicly, can anyone see the difference between these two?
SQL:
UPDATE Sykkel
SET leidut = 0
WHERE CONCAT(sykkel_nr, ' ', sykkel_type) = "a001 Terrengsykkel"
VB:
Dim sqlUpdate As New MySqlCommand("UPDATE Sykkel SET leidut = 1 WHERE CONCAT(sykkel_nr, ' ', sykkel_type) = " & " " & itemChecked, conn)
|

November 22nd, 2011, 04:00 AM
|
|
|
Quote: | Originally Posted by oyb1n Basicly, can anyone see the difference between these two?
SQL:
UPDATE Sykkel
SET leidut = 0
WHERE CONCAT(sykkel_nr, ' ', sykkel_type) = "a001 Terrengsykkel"
VB:
Dim sqlUpdate As New MySqlCommand("UPDATE Sykkel SET leidut = 1 WHERE CONCAT(sykkel_nr, ' ', sykkel_type) = " & " " & itemChecked, conn) |
EDIT:
itemChecked values "a001 Terrengsykkel"
|

November 22nd, 2011, 03:34 PM
|
|
|
|
SQL is not the name of a database management system either. SQL is the name of the scripting language used by most database systems.
Use the debugger to see if your sql from vb code is the same as your manual sql.
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|