Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB.NET 1.0 > VB.NET 2002/2003 Basics
VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET 2002/2003 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old July 15th, 2007, 10:51 PM
Registered User
Join Date: Jul 2007
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to yzlin04 Send a message via Yahoo to yzlin04
Default Problem in inserting a new row in MS Access

I'm new in vb.net. I have a problem in inserting a new row to a MS Access database table.
There is no error message comes out when i run my program, but when i check my MS Access table, there is no record inserted. So, i don't know which line is incorrect.

Here is my code:

  Dim desc, itemID As String

        itemID = txtItemID.Text
        desc = txtItemDesc.Text

        Dim myOleDbConnection As OleDb.OleDbConnection
        Dim insertCommand As String
        Dim myConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\Lecture\CS220\Program backup 3\Ai Ling Ka Salon System\database\login.mdb;User ID=Admin;Password=;"

        insertCommand = "INSERT INTO tblLogin (username, password) VALUES(desc, itemID);"

        myOleDbConnection = New OleDb.OleDbConnection(myConnectionString)

        Dim myOleDbCommand As New OleDb.OleDbCommand(insertCommand, myOleDbConnection)

        myOleDbCommand = myOleDbConnection.CreateCommand

        myOleDbCommand.CommandType = CommandType.Text

        myOleDbCommand.CommandText = insertCommand


        Dim temp_num As Integer
            temp_num = myOleDbCommand.ExecuteNonQuery
        Catch ex As Exception

        End Try


Old July 16th, 2007, 08:03 AM
Friend of Wrox
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi

hi there... you are not receiving any error in the trace window??? you insert code is wrong, you are not sending any values to insert (you are sending something, but they are not string, not even others values..)



================================================== =========
Read this if you want to know how to get a correct reply for your question:
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
================================================== =========
I know that CVS was evil, and now i got the proof:
================================================== =========
Old July 18th, 2007, 11:11 PM
Registered User
Join Date: Jul 2007
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to yzlin04 Send a message via Yahoo to yzlin04

thanks for the help. now my code works already.

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with inserting a new row in MS Access yzlin04 VB Databases Basics 0 July 15th, 2007 11:23 PM
having problem in inserting in access database alto ASP.NET 2.0 Basics 4 May 24th, 2007 08:57 PM
problem with inserting images in Access report pankaj_daga Access 1 February 1st, 2007 08:45 AM
Insert row into MS-ACCESS database ITladybug ADO.NET 1 January 28th, 2006 07:57 AM
Problem with inserting data into an Access DB donrafeal ASP.NET 2.0 Basics 0 January 6th, 2006 05:34 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.