On a side note, using dynamic SQL like this is dangerous. Leaves your DB
open to SQL injection. Have you considered a parameterized stored procedure?
It will help you safe your DB and you will enjoy a performance increase.   It
may also help with debugging as the error will most likely tell you you are
missing a value. Just my $0.02






On Fri, Oct 31, 2008 at 10:02 AM, Imstac <[EMAIL PROTECTED]> wrote:

>
> Thank you sooo much!  This was the problem.
>
> On Oct 30, 5:41 pm, "Subrato Mukherjee" <[EMAIL PROTECTED]>
> wrote:
> > I do not think its because of missing single quote but rather a missing
> > value itself. I have encountered this kind of problem in which an integer
> > value was blank leading to a statement like (.....,'xyz',,...) This
> causes a
> > problem at SQL end. So if you have such empty values coming through, make
> > them zero or something similar so no null value is passed
> > Hope this helps
> >
> >
> >
> > On Thu, Oct 30, 2008 at 6:09 PM, Imstac <[EMAIL PROTECTED]> wrote:
> >
> > > I added an SQL insert statement to a button on my web form and when I
> > > debug I get the error: "Incorrect syntax near ','  "  I've been over
> > > and over the code and can't figure out the problem.  Could someone
> > > please take a look at my code and let me know if you see anything
> > > wrong?
> >
> > > Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
> > > System.EventArgs) Handles Button1.Click
> > >        Dim oConn As New
> >
> > >
> System.Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings(­"CMSConnectionString").ConnectionString)
> > >        Dim cmd As New System.Data.SqlClient.SqlCommand()
> > >        cmd.Connection = oConn
> > >        oConn.Open()
> > >        cmd.CommandText = "INSERT into
> > > Timecard(INEENO,INDTWE,INWKNO,INDYWK, INJBNO, INGLAN, INJCDI, INRGHR,
> > > INOVHR, INOTHR, INOTTY) values(" & EmplID1.Text & ",'" &
> > > DatePicker1.TextValue & "'," & DD_week.Text & "," & DD_DayofWeek.Text
> > > & ",'" & jobno.Text & "','" & GLAcct.Text & "','" & DD_CostCode.Text &
> > > "'," & RegHrs.Text & ", " & OTHrs.Text & "," & OthHrs.Text & ",'" &
> > > DD_OthHourType.Text & "')"
> > >        cmd.ExecuteNonQuery()
> > >        oConn.Close()
> >
> > >    End Sub- Hide quoted text -
> >
> > - Show quoted text -




-- 
_______________________________

Take care,
Paul

It is not we non-interventionists who are isolationists. The real
isolationists are those who impose sanctions and embargos on countries and
peoples across the globe and who choose to use force overseas to promote
democracy. A counterproductive approach that actually leads the U.S. to be
more resented and more isolated in the world.

Dr. Ron Paul

www.RonPaul2008.com

Reply via email to