Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2006-10-23
6
Medium Priority
?
300 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 18

Expert Comment

by:Ravi Singh
ID: 17787579
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
ID: 17787606
I get error; "Operator "&" is not defined for types "string" ?
0
 
LVL 18

Expert Comment

by:Ravi Singh
ID: 17787834
Hi, whats the type of the variable CSNameNode?  
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

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

0
 
LVL 18

Accepted Solution

by:
Ravi Singh earned 1000 total points
ID: 17787896
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
ID: 17787920
Many thanks, its working perfectly now.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

670 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