|
Hello!
I am using TSQL to add to access based database. I have been getting syntax error in INSERT INTO statement. Here is the statement. If you can recognize the error please let me know. Myrequest is a collection and it is working fine.
Thanks!
Dim SrchKey
SrchKey = "INSERT INTO Estates "
SrchKey = SrchKey + "(status,stockno,portfolio,type,city,town,suburb,rooms,heating,age,floor,size,price,exchange,properforcredit,"
SrchKey = SrchKey + "opportunity,listdate,deposit,depositamount,showmainpage,description,picture1,picture2,picture3,picture4,"
SrchKey = SrchKey + "picture5,picture6,RecordStatus,SoldRent,HitCount) VALUES ("
SrchKey = SrchKey & myRequest("status") & ","
SrchKey = SrchKey + "'" & myRequest("stockno") & "',"
SrchKey = SrchKey + "'" & myRequest("portfoy") & "',"
SrchKey = SrchKey + myRequest("type") & ","
SrchKey = SrchKey + myRequest("city") & ","
SrchKey = SrchKey + "'" & myRequest("town") & "',"
SrchKey = SrchKey + "'" & myRequest("suburb") & "',"
SrchKey = SrchKey + "'" & myRequest("rooms") & "',"
SrchKey = SrchKey + "'" & myRequest("heating") & "',"
SrchKey = SrchKey + "'" & myRequest("age") & "',"
SrchKey = SrchKey + "'" & myRequest("floor") & "',"
SrchKey = SrchKey + "'" & myRequest("size") & "',"
SrchKey = SrchKey & clng(myRequest("price")) & ","
SrchKey = SrchKey + "'" & myRequest("exchange") & "',"
SrchKey = SrchKey & myRequest("properforcredit") & ","
SrchKey = SrchKey & myRequest("opportunity") & ","
SrchKey = SrchKey + "'" & myRequest("listdate") & "',"
SrchKey = SrchKey & myRequest("deposit") & ","
SrchKey = SrchKey & myRequest("depositamount") & ","
SrchKey = SrchKey & myRequest("showmainpage") & ","
SrchKey = SrchKey + "'" & myRequest("description") & "',"
SrchKey = SrchKey + "'" & SetFileName(0) & "',"
SrchKey = SrchKey + "'" & SetFileName(1) & "',"
SrchKey = SrchKey + "'" & SetFileName(2) & "',"
SrchKey = SrchKey + "'" & SetFileName(3) & "',"
SrchKey = SrchKey + "'" & SetFileName(4) & "',"
SrchKey = SrchKey + "'" & SetFileName(5) & "',"
SrchKey = SrchKey & -1 & ","
SrchKey = SrchKey & False & ","
SrchKey = SrchKey & 0 & ");"
|
|
|
|
|
Its near on impossible to tell you what the syntax error is from what you have provided, but here are some tips.
1) You are mixing '+' and '&' for string concatentation - pick one and stick with it.
2) You should not be building up a SQL query in this way, it is unsafe and leaves you open to SQL Injection attacks.
3) Try writing out the content of SrchKey after building this string to a messagebox (for example) - it will help you spot the error (Which is likely to be a missing quote, or a missing comma)
Current blacklist
svmilky - Extremely rude | FeRtoll - Rude personal emails | ironstrike1 - Rude & Obnoxious behaviour
|
|
|
|
|
Hmmm.... A few things...
1. Be consistent with the string concatenation... use & rather than +.
2. Put single quotes around all string values. SQL won't accept them otherwose.
3. Check that any numeric values you enter are properly constructed in VB (e.g. this line SrchKey = SrchKey & -1 & "," really should be like this SrchKey = SrchKey & "-1," .
4. Debug the app and breakpoint at the point where the entrie string has been constructed. Inspect it for syntax errors.
...Steve
1. quod erat demonstrandum
2. "Give a man a fish and you've fed him for a day. Teach him how to fish and you've fed him for life." I read that somewhere once
|
|
|
|
|
And for the love of SQL, scrap this thing and use a parameterized query instead!! You've just found out one huge reason why!! Search the articles for "SQL Injection" and look for the article by Colin Angus Mackay. It has an explaination of how to do this.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi,
I have an application that compresses SQL data backups and writes it to a DVD-RAM drive on a daily basis.
How could programmatically format the DVD in VB6/.Net?
Thanxs!
you can't forget something you never knew...
|
|
|
|
|
There is nothing in the Win32 API that will do this. You'll have to find an application that does this already or see if there is an SDK for the DVD burner software that you have installed.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Dave Kreskowiak wrote: You'll have to find an application that does this already
How did these guys do it?
Thanks, at least I know to stop trying to code it myself.
you can't forget something you never knew...
|
|
|
|
|
Getting to know the drivers inside and out, and knowing the commands the drivers and drives understand and using the Win32 function DeviceIoControl[^] to send them...
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
How is it possible to set the size of the grouptree in a Crystalreportviewer object? This is only possible at runtime. The only available option is to display or hide the grouptree (using the DisplayGroupTree value).
-- modified at 9:45 Tuesday 25th April, 2006
|
|
|
|
|
Hi all,
Is there a book or web site that has all error codes listed with a good description of what each one means?
Thanks, Garner
|
|
|
|
|
Ive always found google to be perfect for this, just paste the error code or error message into the search and you will find a plethora of discussion on that error.
Current blacklist
svmilky - Extremely rude | FeRtoll - Rude personal emails | ironstrike1 - Rude & Obnoxious behaviour
|
|
|
|
|
I want shutdown a computer in the LAN. Who help me !
nguyen kiem
|
|
|
|
|
CodeProject article.
Somebody didn't search before he posted
--------------------------------------------------------
My development blog
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|
|
Without you giving us a valid reason to do this, and the very vague description, we have no idea WHY you want to do it - maybe it is for malicious purposes? We just don't know, so no - no one is likely to help you with this question.
...Steve
1. quod erat demonstrandum
2. "Give a man a fish and you've fed him for a day. Teach him how to fish and you've fed him for life." I read that somewhere once
|
|
|
|
|
The solution on my link requiers a software to be installed on the "target" computer.
But yes I agree with you
--------------------------------------------------------
My development blog
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|
|
|
guys i am a newbie in vb.net programming and want to seek help regarding my current program..i have an existing access database and want to use vb.net as to generate a report.question is how can i access a certain data(say "account") in a table named "customers" so that when i click the "search" button on the main form, all of the data in "account" will be loaded in another form...thanks.
|
|
|
|
|
start with this
<a>http://www.startvbdotnet.com/ado/msaccess.aspx</a>
|
|
|
|
|
|
How can I write a application, so that it can be startup in web?
May I have a detail step to do so?
|
|
|
|
|
If I understand your question, you want to write an ASP.NET application. This will be web-based and run through a browser.
Current blacklist
svmilky - Extremely rude | FeRtoll - Rude personal emails | ironstrike1 - Rude & Obnoxious behaviour
|
|
|
|
|
Um ...
However, The application is using to get and create a number of files in client side...
So, I think it should not be in ASP.NET ...
|
|
|
|
|
By default, a web application doesn't have the permissions to do this. For security reasons, the machines file system and other hardware resources are off-limits to any code running inside a web browser.
For any further information, you're going to have to explain what you want to do in greater detail.
Dave Kreskowiak
Microsoft MVP - Visual Basic
-- modified at 15:38 Tuesday 25th April, 2006
|
|
|
|
|
Thank you first.
In my task, I need to get some files from the client machine with some input and save them to file server and add a row in database.
I have a application to do so.
However, In some case, the user will need to reference the old file which display in a asp, I would like to pass the reference (a integer) to the client application, so that the application can indicate that the relationship between the two files (Actually, I am going to do file versioning.) I am finding a solution that user no need to enter any key to do that, but just a click for check out the document and then open the client application to finish the process. (I cannot simply use the asp upload since the user selected a file and the application will have some process in client machine, I don't want those process done in server.)
|
|
|
|
|
hi there
if i try ti minimize the form , or if i open any other application then it is throughing an error. Please help me i am unable to trace the cause as it is also showing the message source cannot be found for this error.
thanks in advance.
bharath.s
|
|
|
|