?
Solved

Updation query in Access through VB.net

Posted on 2006-07-13
4
Medium Priority
?
217 Views
Last Modified: 2010-04-23
Hello experts I am working on an application where I update the MsAccess database by coding. Now I am stuck with minor error but i did't able to rectify.
please tell me what's error in this code as it show me the syntax error
Private Sub updateAppNote()
        If AppConn.State.ToString = "Closed" Then
            AppConn.Open()
        End If
       
        Dim SQL As String = "UPDATE Applicant_Note " & _
        "set Time_Stamp='" & Now.ToShortDateString & " " & Now.ToShortTimeString & "', Note='" & txtnote.txt  & _
        "' Where NID=" & CLng(dgvNoteList.CurrentRow.Cells(0).Value)

        MsgBox(SQL)
        Dim Dc As New OleDbCommand(SQL, AppConn)
        Dc.ExecuteNonQuery()
        AppConn.Close()
0
Comment
Question by:EmmanuelNwokedi
  • 3
4 Comments
 
LVL 35

Expert Comment

by:YZlat
ID: 17100760
If AppConn.State = ConnectionState.Closed Then
            AppConn.Open()
        End If
0
 
LVL 35

Accepted Solution

by:
YZlat earned 100 total points
ID: 17103706
also when using Access database you should wrap Date values in #. Is Time_Stamp a string field or a date field?

If date, then do:

 Dim SQL As String = "UPDATE Applicant_Note " & _
        "set Time_Stamp=#" & Now & "#, Note='" & txtnote.txt  & _
        "' Where NID=" & CLng(dgvNoteList.CurrentRow.Cells(0).Value)

if it's a string, use

Dim SQL As String = "UPDATE Applicant_Note " & _
        "set Time_Stamp='" & Now.ToShortDateString.ToString & " " & Now.ToShortTimeString.ToString & "', Note='" & txtnote.txt  & _
        "' Where NID=" & CLng(dgvNoteList.CurrentRow.Cells(0).Value)

or

Dim SQL As String = "UPDATE Applicant_Note " & _
        "set Time_Stamp='" & Now.ToString & "', Note='" & txtnote.txt  & _
        "' Where NID=" & CLng(dgvNoteList.CurrentRow.Cells(0).Value)

0
 

Author Comment

by:EmmanuelNwokedi
ID: 17106640
Hello experts I am working on an application where I update the MsAccess database by coding. Now I am stuck with minor error but i did't able to rectify.
please tell me what's error in this code as it show me the "syntax error in update statement"
I try with every possible way still it show me the same error. Please Help me out
Private Sub updateAppNote()
        If AppConn.State.ToString = "Closed" Then
            AppConn.Open()
        End If
       
        Dim SQL As String = "UPDATE Applicant_Note " & _
        "set Time_Stamp='" & now & "', Note='" & txtnote.text  & _
        "' Where NID=" & CLng(dgvNoteList.CurrentRow.Cells(0).Value)

        MsgBox(SQL)
        Dim Dc As New OleDbCommand(SQL, AppConn)
        Dc.ExecuteNonQuery()
        AppConn.Close()
0
 
LVL 35

Expert Comment

by:YZlat
ID: 17109142
Dim SQL As String = "UPDATE Applicant_Note " & _
        "set Time_Stamp=#" & now & "#, Note='" & txtnote.text  & _
        "' Where NID=" & CLng(dgvNoteList.CurrentRow.Cells(0).Value)
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question