Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Adding a record to MS Access DB
Message
 
To
All
General information
Forum:
ASP.NET
Category:
ADO.NET
Title:
Adding a record to MS Access DB
Miscellaneous
Thread ID:
00689664
Message ID:
00689664
Views:
49
Hi,

I'm trying to add a record an Access DB with the following code in a VB.Net webform:
Private Function fnAddtoDatabase() As Boolean

        Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0; DATA Source=c:\Inetpub\wwwroot\database\LuckyDog.mdb;"
        Dim objConn As New System.Data.OleDb.OleDbConnection(strConn)
        Dim objCmd As New System.Data.OleDb.OleDbCommand()
        Dim strSQL As String
        
        strSQL = "Insert Into DataDictRegistration(FirstNameVC,LastNameVC,CityVC," _
               & "StateVC,CountryVC,EMailVC,CompanyNameVC,ReceiveUpdatesBT) " _
               & "VALUES('" & strFirstName & "'," _
               & "'" & strLastName & "'," _
                & "'" & strCity & "'," _
                & "'" & strState & "'," _
                & "'" & strCountry & "'," _
                & "'" & strEMail & "'," _
                & "'" & strCompany & "'," _
                & "'" & strInfo & "')"

        objCmd.CommandType = CommandType.Text
        objCmd.CommandText = strSQL
        objCmd.Connection = objConn
    
        objConn.Open()

        objCmd.ExecuteNonQuery()

        objConn.Close()

        fnAddtoDatabase = True

    End Function
When I try this, I get the following error information on "objCmd.ExecuteNonQuery()" ...
[OleDbException (0x80004005): Operation must use an updateable query.]
Any idea what I'm doing wrong here (by the way, I do intend to add "Try,Catch..." error handling once I get past this hurdle) ?
Al Williams

Anola MB, CANADA
Next
Reply
Map
View

Click here to load this message in the networking platform