Solved

VB.net MySQL Query - Expected end of statement error?

Posted on 2006-10-23
6
279 Views
Last Modified: 2011-10-03
Experts,

I have the following query;

Dim SQLQuery As String = "Insert Into Hardware (ID, CSName) VALUES ('" "', '" CSNameNode "')"

I am getting "expected end of statement" error.... I cannot see what is wrong with this query.

0
Comment
Question by:nickmarshall
  • 3
  • 3
6 Comments
 
LVL 18

Expert Comment

by:Ravi Singh
Comment Utility
Hi, you need to concatenate the string with the CSNameNode string using the & operator:

   Dim SQLQuery As String = "Insert Into Hardware (ID, CSName) VALUES (' ', '" & CSNameNode & "')"

Is ID an auto incremenet field in your database? If so you don't need to include it in the insert statement:

   Dim SQLQuery As String = "Insert Into Hardware (CSName) VALUES ('" & CSNameNode & "')"
0
 
LVL 1

Author Comment

by:nickmarshall
Comment Utility
I get error; "Operator "&" is not defined for types "string" ?
0
 
LVL 18

Expert Comment

by:Ravi Singh
Comment Utility
Hi, whats the type of the variable CSNameNode?  
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 1

Author Comment

by:nickmarshall
Comment Utility
Dim CSNameNode As XmlNode = XmlDoc.DocumentElement.SelectSingleNode("//CSName")
CSNameNode.InnerText.ToString()

0
 
LVL 18

Accepted Solution

by:
Ravi Singh earned 250 total points
Comment Utility
Try:

Dim SQLQuery As String = "Insert Into Hardware (ID, CSName) VALUES (' ', '" & CSNameNode.InnerText & "')"

or with the other sql query:

Dim SQLQuery As String = "Insert Into Hardware (CSName) VALUES ('" & CSNameNode.InnerText & "')"
0
 
LVL 1

Author Comment

by:nickmarshall
Comment Utility
Many thanks, its working perfectly now.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now