Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB Databases Basics
|
VB Databases Basics Beginning-level VB coding questions specific to using VB with databases. Issues not specific to database use will be redirected to other forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB Databases 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, 11:23 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 with inserting a new row in MS Access

Hello,
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

        myOleDbConnection.Open()

        Dim temp_num As Integer
        Try
            temp_num = myOleDbCommand.ExecuteNonQuery
        Catch ex As Exception
            Trace.WriteLine(ex.ToString)

        End Try

        myOleDbConnection.Close()







Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem in inserting a new row in MS Access yzlin04 VB.NET 2002/2003 Basics 2 July 18th, 2007 11:11 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.