|
Hi,
I am inserting records into ms access using vb.net.
insert into data(F01,F02)values(" & F01(k) & "," & IIf(Double.IsNaN(F01TA(k)), DBNull.Value, F01TA(k)) & ")"
Showing syntax error in the insert statement.
the output query is like below
insert into Data(F01,F02)values(221,);
Please share your ideas...
Thanks,
Sivakumar.M.
|
|
|
|
|
check the value of the given parameters... your generated query probably like ...
....Values(1,2,,3)
I will not say I have failed 1000 times; I will say that I have discovered 1000 ways that can cause failure – Thomas Edison.
Don't forget to click [Vote] / [Good Answer] on the post(s) that helped you.
Thanks
Md. Marufuzzaman
|
|
|
|
|
What is the Error that you are getting ?
Your insert is incorrect, Your expected number of parameters is less than the Supplied Parameters.
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
When you concatenate DBNull.Value into your query expression, it calls the DBNull.ToString method. This is defined to return an empty string, so your insert statement is missing a parameter after the final comma.
Use the literal "null" in your SQL insert instead of DBNull.Value, that should work. Or use a DbCommand with query parameters, as someone else suggested.
|
|
|
|
|
Hi all,
I need to insert a record in to a table automatically on every day at 12 PM.How can I achive this.Will trigger help me in this regard.If not how can I achive this.Please help me.(I want to perform this action in backend only)
Thanks in advance,
Srinivas Mateti
|
|
|
|
|
You can create a Job , which db are you using ???
Best Of Regards,
SOFTDEV
If you have knowledge, let others light their candles at it
|
|
|
|
|
I will be using both MSSQL and MySQL data bases.
Thanks,
Srinivas Mateti
|
|
|
|
|
MSSQL you can create a stored procedure to do the insert and then schedule a job to execute the procedure when required.
MySQL - I don't know.
As suggested you could use a windows service to do both inserts.
|
|
|
|
|
Thanks for the reply.Here the constraint is I cannot use Windowse services.So, I will schedule a job whichi will fire on each day at specific time.In this job i will call the SP which will insert or update the desired record.I hore in MYSQL ALSO it will works.Right....
Thanks,
Srinivas Mateti
|
|
|
|
|
If MySQL does not support jobs then you may be able to trick SQL Server into doing the job on MySQL as a remote server or a linked server, nasty but it may be possible.
|
|
|
|
|
Oho..This will create more problem for me.I cannot use SQLSERVER to trigger MYSQL.I canot use windowse services.But I need the auto insert action...Is there any other option in MySQl which is similar to MSSQL jobs feature.Please guide me.
Thanks in advance,
Srinivas Mateti
|
|
|
|
|
MySQL has an event scheduler which can be used to fire off tasks at specified times or intervals.
|
|
|
|
|
Triggers execute in response to certain events when INSERT, UPDATE or DELETE
|
|
|
|
|
So in this case I cant use triggers..right?
|
|
|
|
|
|
u hv to write a windows service for this.where u can set the exact time.
Thanks and Regards
Sujit Kr. Mandal
|
|
|
|
|
no need to invent the wheel again Sql server job will do the job
Best Of Regards,
SOFTDEV
If you have knowledge, let others light their candles at it
|
|
|
|
|
I think you can create a stored procedure for the insertion and call it from a SQL job that's it;
I will not say I have failed 1000 times; I will say that I have discovered 1000 ways that can cause failure – Thomas Edison.
Don't forget to click [Vote] / [Good Answer] on the post(s) that helped you.
Thanks
Md. Marufuzzaman
|
|
|
|
|
Hi I am in process of designing a online employee timesheet application which allows employee to record hours and manager to approve number of hours worked. could someone please point me to links which gives me idea on how to create tables i.e. employee, timecard, etc
|
|
|
|
|
Hi uglyeyes--
You have been a member long enough that CodeProject is not here to answer generic questions such as these. Your question is one where most would probably tell you to "just Google it." Creating a basic database and its tables is part of the learning process. Sit down, take some time, and think it out.
|
|
|
|
|
What exactly is your question?
How to create table called employee, timecard etc in some database?
or
You are looking for guidance related to database design?
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
Which Tools are you using to do this , you have not explain that you are going to use Sql Server or MySql , for online System i will recommend MySql any how here is the link for Ms Sql Server
http://databases.about.com/od/sqlserver/ss/sqlservertables.htm[^]
Best Of Regards,
SOFTDEV
If you have knowledge, let others light their candles at it
|
|
|
|
|
u can create this sample tables
CREATE TABLE [dbo].[ATTENDANCE](
[AttendanceID] [int] IDENTITY(1,1) NOT NULL,
[EmployeeID] [int] NULL,
[AttendanceCreatedDate] [datetime] NULL,
[AttendanceCreatedByUserID] [int] NULL,
[AttendanceDate] [datetime] NULL,
[InTime] [datetime] NULL,
[OutTime] [datetime] NULL,
[WorkDuration] [int] NULL,
[IsOverTime] [bit] NULL CONSTRAINT [DF_Attendance_IsOverTime] DEFAULT ((0)),
[AttendanceComments] [varchar](1000) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
CONSTRAINT [PK_Attendance] PRIMARY KEY CLUSTERED
(
[AttendanceID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
CONSTRAINT [UK_Attendance] UNIQUE NONCLUSTERED
(
[EmployeeID] ASC,
[AttendanceDate] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
Thanks and Regards
Sujit Kr. Mandal
|
|
|
|
|
Hi Guys,
thanks for your response. I should have been more specific. I have already created few tables which are as below.
Employee, EmployeeType, Jobtitle,
Period (PeriodId PeriodStartDate PeriodEndDate),
timeCard(TimeCardId,PeriodId,EmployeeId,Date,StartTimeAM,EndTimeAM,StartTimePM,EndTimePM,BreakTaken,UpdatedDate,IsApproved)
period
17 2009-09-21 00:00:00 2009-09-27 00:00:00
timecard for one week for one employee
1 17 1 2009-09-21 00:00:00 1900-01-01 06:15:00 1900-01-01 11:30:00 1900-01-01 17:15:00 1900-01-01 12:00:00 1900-01-01 01:00:00 2009-10-01 11:38:00 0
2 17 1 2009-09-22 00:00:00 1900-01-01 06:15:00 1900-01-01 11:30:00 1900-01-01 17:15:00 1900-01-01 12:00:00 1900-01-01 01:00:00 2009-10-01 11:38:00 0
3 17 1 2009-09-23 00:00:00 1900-01-01 06:15:00 1900-01-01 11:30:00 1900-01-01 17:15:00 1900-01-01 12:00:00 1900-01-01 01:00:00 2009-10-01 11:38:00 0
4 17 1 2009-09-24 00:00:00 1900-01-01 06:15:00 1900-01-01 11:30:00 1900-01-01 17:15:00 1900-01-01 12:00:00 1900-01-01 01:00:00 2009-10-01 11:38:00 0
5 17 1 2009-09-25 00:00:00 1900-01-01 06:15:00 1900-01-01 11:30:00 1900-01-01 17:15:00 1900-01-01 12:00:00 1900-01-01 01:00:00 2009-10-01 11:38:00 0
6 17 1 2009-09-26 00:00:00 1900-01-01 06:15:00 1900-01-01 11:30:00 1900-01-01 17:15:00 1900-01-01 12:00:00 1900-01-01 01:00:00 2009-10-01 11:38:00 0
7 17 1 2009-09-27 00:00:00 1900-01-01 06:15:00 1900-01-01 11:30:00 1900-01-01 17:15:00 1900-01-01 12:00:00 1900-01-01 01:00:00 2009-10-01 11:38:00 0
for you to understand I have provided columns of period and timecard. this web application is used by hospitality industry.
employee works shifts like 7am-12pm and 6pm-2am
Now, I am thinking I shouldnt store computed values.
My problem is how do i work it out below:
If they work after mid-night they should get penalty and those two hours after midnight should be moved to record
also I dont know how to calculate their pay.
could you please help?
|
|
|
|
|
Ok, to simply it. how can I compare the time value as an input. my idea is if they type endtime anything bigger than 12.00am I need to compare mid-night time and @endtime, if @endtime is after midnight I need to add to append the hours next day in next row.
declare @starttime smalldatetime
declare @endtime smalldatetime
set @starttime='18:20'
set @endtime ='2:00'
print DATEADD(hh, DATEPART(hour,@EndTime), DATEADD(mi,DATEPART(mi,@EndTime),DATEADD(dd, DATEDIFF(dd, 0, GETDATE()), 0)) )
print DATEADD(dd, DATEDIFF(dd, 0, GETDATE()),0)
Hope that makes sense?
thank you
modified on Monday, October 5, 2009 8:45 PM
|
|
|
|
|