Solved

Updation query in Access through VB.net

Posted on 2006-07-13
4
213 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 50 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
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…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

729 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