Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 21st, 2011, 07:19 AM
oyb1n oyb1n is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2011
Posts: 17 oyb1n User rank is Sergeant (500 - 2000 Reputation Level)oyb1n User rank is Sergeant (500 - 2000 Reputation Level)oyb1n User rank is Sergeant (500 - 2000 Reputation Level)oyb1n User rank is Sergeant (500 - 2000 Reputation Level)oyb1n User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 3 h 1 m 53 sec
Reputation Power: 0
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.

Reply With Quote
  #2  
Old November 21st, 2011, 07:03 PM
Doug G Doug G is offline
Grumpier Old Moderator
Dev Shed God 19th Plane (14000 - 14499 posts)
 
Join Date: Jun 2003
Posts: 14,257 Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 4 Weeks 18 h 51 m 19 sec
Reputation Power: 4445
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

Reply With Quote
  #3  
Old November 22nd, 2011, 03:14 AM
oyb1n oyb1n is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2011
Posts: 17 oyb1n User rank is Sergeant (500 - 2000 Reputation Level)oyb1n User rank is Sergeant (500 - 2000 Reputation Level)oyb1n User rank is Sergeant (500 - 2000 Reputation Level)oyb1n User rank is Sergeant (500 - 2000 Reputation Level)oyb1n User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 3 h 1 m 53 sec
Reputation Power: 0
Quote:
Originally Posted by Doug G
What is a phpsql database? Never heard of it.


Haha sorry, SQL

Reply With Quote
  #4  
Old November 22nd, 2011, 03:59 AM
oyb1n oyb1n is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2011
Posts: 17 oyb1n User rank is Sergeant (500 - 2000 Reputation Level)oyb1n User rank is Sergeant (500 - 2000 Reputation Level)oyb1n User rank is Sergeant (500 - 2000 Reputation Level)oyb1n User rank is Sergeant (500 - 2000 Reputation Level)oyb1n User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 3 h 1 m 53 sec
Reputation Power: 0
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)

Reply With Quote
  #5  
Old November 22nd, 2011, 04:00 AM
oyb1n oyb1n is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2011
Posts: 17 oyb1n User rank is Sergeant (500 - 2000 Reputation Level)oyb1n User rank is Sergeant (500 - 2000 Reputation Level)oyb1n User rank is Sergeant (500 - 2000 Reputation Level)oyb1n User rank is Sergeant (500 - 2000 Reputation Level)oyb1n User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 3 h 1 m 53 sec
Reputation Power: 0
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"

Reply With Quote
  #6  
Old November 22nd, 2011, 03:34 PM
Doug G Doug G is offline
Grumpier Old Moderator
Dev Shed God 19th Plane (14000 - 14499 posts)
 
Join Date: Jun 2003
Posts: 14,257 Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 4 Weeks 18 h 51 m 19 sec
Reputation Power: 4445
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.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > PhpSQL/VB help with code

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap