Results 1 to 7 of 7

Thread: [RESOLVED] insert command

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2005
    Posts
    162

    Resolved [RESOLVED] insert command

    is there something wrong with the insert sql string in sql ce?
    i am using "insert into table (field1) values (value1);" and it tells me that that is an unacceptable command in sqlce. what is the other way to do variables?
    it looks something like this
    VB Code:
    1. insert into table (field1) values (?)
    2. cecmd.sqlparamets.add("field1", value1)
    can i get a little help?

  2. #2
    Fanatic Member Strider's Avatar
    Join Date
    Sep 2004
    Location
    Dublin, Ireland
    Posts
    612

    Re: insert command

    Is this what you mean?

    Dim value1 As String = "xxxxx"

    INSERT INTO Table (field1) Values ('" & value1 & "')"
    Barry


    Visual Studio .NET 2008/Visual Studio .NET 2005/Visual Studio .NET 2003
    .NET Framework 3.0 2.0 1.1/ASP.Net 3.0 2.0 1.1/Compact Framework 1.0

    SQL Server 2005/2000/SQL Server CE 2.0


    If you like, rate this post

    Compact Framework for Beginners

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    May 2005
    Posts
    162

    Re: insert command

    no it looks like what i posted. "the function is not recognized by sql server"

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    May 2005
    Posts
    162

    Re: insert command

    VB Code:
    1. Dim cecmd As SqlCeCommand = New SqlCeCommand( _
    2.                 "insert into received (jobnum, boxnum, weight, numberrecvd, bay, recdate)" & _
    3.                  " values (" & CInt(lblJobnum.Text) & ", " & CInt(txtBoxnum.Text) & ", " & _
    4.                 CDec(txtWeight.Text) & ", " & CInt(txtNReceived.Text) & ", '" & _
    5.                 txtBay.Text & "', now());", ceconn)
    6.                 cecmd.ExecuteNonQuery()

  5. #5
    Fanatic Member Strider's Avatar
    Join Date
    Sep 2004
    Location
    Dublin, Ireland
    Posts
    612

    Re: insert command

    use getDate() instead of now()
    dont think there is any need for the ; at the end, well i never use it anyway.
    Barry


    Visual Studio .NET 2008/Visual Studio .NET 2005/Visual Studio .NET 2003
    .NET Framework 3.0 2.0 1.1/ASP.Net 3.0 2.0 1.1/Compact Framework 1.0

    SQL Server 2005/2000/SQL Server CE 2.0


    If you like, rate this post

    Compact Framework for Beginners

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    May 2005
    Posts
    162

    Re: insert command

    now is an sql command for datetime which is what i need. anyway i fixed my problem.

  7. #7
    Fanatic Member Strider's Avatar
    Join Date
    Sep 2004
    Location
    Dublin, Ireland
    Posts
    612

    Re: [RESOLVED] insert command

    getDate() does the same, its sql servers in built function of getting the date & time from the device
    Barry


    Visual Studio .NET 2008/Visual Studio .NET 2005/Visual Studio .NET 2003
    .NET Framework 3.0 2.0 1.1/ASP.Net 3.0 2.0 1.1/Compact Framework 1.0

    SQL Server 2005/2000/SQL Server CE 2.0


    If you like, rate this post

    Compact Framework for Beginners

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width