Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 2005 > Visual Basic 2005 Basics
|
Visual Basic 2005 Basics If you are new to Visual Basic programming with version 2005, this is the place to start your questions. For questions about the book: Beginning Visual Basic 2005 by Thearon Willis and Bryan Newsome, ISBN: 0-7645-7401-9 please, use this forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Basic 2005 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 March 3rd, 2006, 03:25 AM
Registered User
 
Join Date: Mar 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Insert New Row into Table (VB 2005)

hi..i'm trying to insert a new row into table, but it always fail.
this is my code :

 Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
        strSQL2 = "INSERT INTO HISTORY VALUES ('" & txt01.Text & "'," & _
                                            " '" & txt02.Text & "'," & _
                                            " '" & txt03.Text & "'," & _
                                            " '" & txt04.Text & "'," & _
                                            " '" & txt05.Text & "'," & _
                                            " '" & txt06.Text & "'," & _
                                            " '" & txt07.Text & "'," & _
                                            " '" & txt08.Text & "'," & _
                                            " '" & txt09.Text & "'," & _
                                            " '" & txt10.Text & "'," & _
                                            " '" & txt11.Text & "'," & _
                                            " '" & txt12.Text & "'," & _
                                            " '" & txt13.Text & "')"
        Con.ConnectionString = "Provider = microsoft.jet.oledb.4.0; data source = c:\Event2.mdb"
        Com2 = New OleDb.OleDbCommand(strSQL2, Con)
        Con.Open()
        Try
            result = Com.ExecuteNonQuery()
            If (result > 0) Then
                MsgBox("Success")
            End If
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        End Try
        If Com IsNot Nothing Then Com.Dispose()
        Con.Close()
    End Sub

Please i need your help, please correct my code.
in advance, thank you very much for your help.





Similar Threads
Thread Thread Starter Forum Replies Last Post
insert row into table stealthdevil Access VBA 11 June 16th, 2007 08:32 AM
insert from one table to 2nd if row already exists brocktune SQL Server 2000 2 May 15th, 2007 12:56 AM
How I insert button into table for select row. oatza ASP.NET 2.0 Basics 5 May 10th, 2006 12:09 AM
Problem with insert new row in *.dbo table dimeanel Pro VB.NET 2002/2003 1 January 23rd, 2006 12:05 PM
Insert Row Into Access Table With VBScript ritag Classic ASP Databases 2 August 5th, 2004 08:17 AM





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