473,411 Members | 1,899 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,411 software developers and data experts.

Very Bad Insert statement--Pls help

exedotsree
Hi

Pls help me find out the syntax error in the following stmt...

Expand|Select|Wrap|Line Numbers
  1. Dim insqry As String = "INSERT INTO AssShift(employeeid,departmentid,day" & curdate.Day & ",month,year,lastupdated) VALUES (" & empid & "," & deptid & "," & shid & "," & curdate.Month & "," & curdate.Year & ",#" & Format(Now, shortdateformat) & "#)"
when seen in the addwatch window during run it appears as shown below which seems to be correct...

INSERT INTO AssShift(employeeid,departmentid,day1,month,year,l astupdated) VALUES (249,6,29,3,2008,#3/14/2008#)

when i run this query in MSAccess query,it works fine...
Can any one help me pls....
Mar 14 '08 #1
4 1052
debasisdas
8,127 Expert 4TB
How is it that your field names in the database table is dynamic ???
Mar 14 '08 #2
How is it that your field names in the database table is dynamic ???
Actually the fieldnames are like day1,day2...day31 for storing shift id for each day in a month.

So, while iterating in the loop for day 1 to day 31, i used it
Mar 14 '08 #3
debasisdas
8,127 Expert 4TB
If using Oracle as database try to use EXECUTE IMMEDIATE for dynamic SQL.
Mar 14 '08 #4
If using Oracle as database try to use EXECUTE IMMEDIATE for dynamic SQL.
Hi debasis

I got it solved....the reason is...
there are fieldnames called "month" and "year" which conflicts with keywords.
I altered those fields in the query as [month] and [year] or we can use <tablename>.<fieldname>....

Now its working fine..

Thanks for responding...
Mar 14 '08 #5

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

Similar topics

2
by: Frank Py | last post by:
I need a query that looks at one table and appends another if new customer data is added. I think I need an Insert, Select statement using the NOT IN clause. I need to compare Division,...
4
by: soni29 | last post by:
hi, i have a small question regarding sql, there are two tables that i need to work with on this, one has fields like: Table1: (id, name, street, city, zip, phone, fax, etc...) about 20 more...
9
by: Martin | last post by:
Hello, I'm new with triggers and I can not find any good example on how to do the following: I have two tables WO and PM with the following fields: WO.WONUM, VARCHAR(10) WO.PMNUM,...
2
by: temp999 | last post by:
I was at this web page: http://http://members.shaw.ca/ipatters/ and i was wondering if someone could help me with an insert sort algorithm. I made it all the way to Part 6 until things got tough....
3
by: settyv | last post by:
Hi, I need to generate PDF stream when i click on Linkbutton in datagrid ..At present i hardcoded the DMS Id and now it is working.But i need to pass DMS ID when click linkbutton.How can i do...
6
by: 05l8kr | last post by:
I'm suppose to edit the function called swap_values so that it receives three numbers (not two nubmers) called first , second, and third. These numbers will not be in any special order (for example...
0
by: Balamurugan Ranganathan | last post by:
I want to calculate the execution time of a sql query through C#.net this is to analysis two queries to compare their execution time it is very Urgent Please help me Please help Me ...
0
by: Michael | last post by:
I know I am missing something simple, but I am stuck. When I submit the following for the employee info gets stored in scale1 and scale1 shows the employee number. Can someone show me my...
0
by: bgreer5050 | last post by:
I know I am missing something simple, but I am stuck. When I submit the following for the employee info gets stored in scale1 and scale1 shows the employee number. Can someone show me my...
2
by: dotnetnovice | last post by:
Hi everybody! I have a problem and need help Here is the code. public void GetAllValues(Person V) { SqlConnection conn = new SqlConnection(ConnectionString); ...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.