Re: Asp.net vb.net Problem
I'am using visual studio 2010 Express and .net framework 4.0
Re: Asp.net vb.net Problem
When concatenating strings you should use & rather than +
When concatenating numeric vars into your string you should use the .ToString method which is the source of the error in your picture.
MyString ="Some Text " & MyNumber.ToString & " More Text"
[SOLVED] Asp.net vb.net Problem
Thanks DataMiser,
That solved it.
This is the updated line of code that I changed:
Code:
sqlString = "UPDATE tbl_batch SET orignal = " & shift & " WHERE batchNumber = '" & batch & "' AND jobId = " & job & " "
Notice my batch parameter is a string so it must be wrapped in single quotes.
You were absolutely right I was using the wrong concatenation for strings i.e. + is wrong, & is right ...
In vb 6 it is ----> &
in vb.net it is -----> +
in vb.net and Mysql once again it is -----> &
Thanks so much,
I really appreciate it.
Colm
Re: Asp.net vb.net Problem
Quote:
In vb 6 it is ----> &
in vb.net it is -----> +
in vb.net and Mysql once again it is -----> &
Actually it is & in all versions of VB after VB3 including all versions of VB.Net
+ will work in all of them as well but you should always use & as of VB4 and later
Re: Asp.net vb.net Problem
Quote:
In vb 6 it is ----> &
in vb.net it is -----> +
in vb.net and Mysql once again it is -----> &
Actually it is & in all versions of VB after VB3 including all versions of VB.Net
+ will work in all of them as well but you should always use & as of VB4 and later
You should also be using .ToString on those values that are numeric vars. such as shift should be shift.ToString
I take it that you do not have option strict enabled as it would be triggering an error complaining about mixing variable types if it were
Re: Asp.net vb.net Problem
I will correct that change thank you, i relatively new to this language and this help is great. when you say "option strict enabled" what does this mean and how would it be an advantage to me?
Thank you,
Really appreciate the help again
Re: Asp.net vb.net Problem
Basically it forces a more strict method of coding and can help to eliminate runtime errors by alerting you to them when you are still in the IDE. There are options in the IDE for Option Explicit and Option Strict.
Option Explicit forces you to declare all variables before using them.
Option Strict forces you to use the correct variable types or conversions.
For example you can combine a string and an integer if Option strict is off but if it is on you must convert one of them to the type of the other. You could add a double to a long without it on but with it will require you to make a conversion or use a different var.
Basically these options force you to write better code and reduce the chance that your program will crash due to miss use of a variable