473,395 Members | 2,689 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Syntax error in INSERT INTO statement

Expand|Select|Wrap|Line Numbers
  1. If TxtName2.Text = "" Then
  2.             MsgBox("please give a Folder Name")
  3.             Exit Sub
  4.  
  5.         Else
  6.             qry1 = "insert into soft (Folderneym"
  7.             qry2 = ") values ( " & TxtName2.Text & "'"
  8.         End If
--> what could be the problem with this code? I erased a double quote, and spaces but it all appears to have DATABASE ERROR, either its a (missing operator) in query expression or an error in string in query..please help asap.. thank you very much. Godbless
Jun 29 '12 #1
2 1756
Rabbit
12,516 Expert Mod 8TB
Please use code tags when posting code.

If it's a text field, then you will need to surround the value in quotes. You're also missing your closing parenthesis.
Jun 29 '12 #2
PsychoCoder
465 Expert Mod 256MB
Just for reference, you want to use Parametrized queries, otherwise you're opening yourself up to Sql Injection attacks.

Given that here's an example of using SqlParameterCollection.AddWithValue

Expand|Select|Wrap|Line Numbers
  1. Public Function LoginToSystemParameterized(un As String, pwd As String) As Boolean
  2.     Dim count As Integer = 0
  3.     Using conn = New SqlConnection("YourConnectionStringHere")
  4.         Dim sql As String = "SELECT COUNT(userId) FROM users WHERE userName = @username AND password = @password"
  5.         Using cmd = New SqlCommand(sql, conn)
  6.             conn.Open()
  7.             cmd.CommandType = System.Data.CommandType.Text
  8.             'now add our parameters
  9.             cmd.Parameters.AddWithValue("@username", un)
  10.          cmd.Parameters.AddWithValue("@password", pwd)
  11.             count = Convert.ToInteger(cmd.ExecuteScalar())
  12.         End Using
  13.     End Using
  14.  
  15.     Return If(count > 0, True, False)
  16. End Function
Jun 30 '12 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: kosta | last post by:
hello! one of my forms communicates with a database, and is supposed to add a row to a table using an Insert statement... however, I get a 'oledb - syntax error' exception... I have double...
2
by: Tim::.. | last post by:
Can someone please tell me why I keep getting the following error from the code below! Error: INSERT statement conflicted with COLUMN FOREIGN KEY constraint...
3
by: jinhy82 | last post by:
Hi! I am currently creating a Registration form which contained: UserID Password, FirstName and LastName. These details would be inserted into Ms Access when I click submi button. But I...
3
by: Nathan Sokalski | last post by:
When trying to submit data to an Access database using ASP.NET I recieve the following error: System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(Int32 hr) +41...
5
by: amitbadgi | last post by:
Hi guys, I am getting the following error in teh insert statement , I am converting this asp application to asp.net, here is teh error, Exception Details:...
2
by: Geoffrey KRETZ | last post by:
Hello, I'm wondering if the following behaviour is the correct one for PostGreSQL (7.4 on UNIX). I've a table temp_tab with 5 fields (f1,f2,f3,...),and I'm a launching the following request :...
1
by: vasanth chandrasekaran | last post by:
The error is :Syntax error in INSERT INTO statement. This is my code: try { DataSet ds1; OleDbConnection ConnSql; OleDbConnection...
9
by: Ed Pisa | last post by:
Hello, I have been working with this problem now for several days. I can delete and Update my data but I can not get it to insert a new record. I receive the syntax error insert into. I am not...
0
by: Ed Pisa | last post by:
Hello, I have been working with this problem now for several days. I can delete and Update my data but I can not get it to insert a new record. I receive the syntax error insert into. I am not...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.