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 November 21st, 2007, 09:10 AM
Registered User
 
Join Date: Sep 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Error BC30455 Argument not specified for parameter

This is the code and the line the error is Using objAccessDB as New WDABASE.
Public Class Form1
    'Private variables and objects
    Private strProvider As String = "SQL Server"

    Private objData As WDABase
    Private objAccessDB As WDABase
    Private Sub optSQLServer_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles optSQLServer.CheckedChanged
        'Enable Labels and TextBoxes For SQL server
        strProvider = "SQL Server"
        lblServer.Text = "Server"
        lblDatabase.Enabled = True
        txtDatabase.Enabled = True
        txtServer.Focus()
    End Sub

    Private Sub btnOpenConnection_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnOpenConnection.Click
        'Initialize a new instance of the data access base class
        objData = New WDABase(strProvider, txtServer.Text, _
        txtDatabase.Text, txtLoginName.Text, txtPassword.Text)

        Try
            'Open the database connection
            objData.OpenConnection()
            'Set the status message
            lblStatus.Text = "Database opened."
        Catch ExceptionErr As Exception
            'Display the error
            MessageBox.Show(ExceptionErr.Message)
        End Try
    End Sub

    Private Sub btnCloseConnection_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnCloseConnection.Click

        'Close the database connection
        objData.CloseConnection()
        'Set the status message
        lblStatus.Text = "Database closed."
        'Cleanup
        objData.Dispose()
        objData = Nothing
    End Sub

    Private Sub optOracle_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles optOracle.Click
        'Disable Lables and TextBoxes for Oracle
        strProvider = "Oracle"
        lblServer.Text = "SID"
        lblDatabase.Enabled = False
        txtDatabase.Enabled = False
        txtServer.Focus()
    End Sub
    Private Sub btnGroups_Click(ByVal sender As Object, _
    ByVal e As System.EventArgs) Handles btnGroups.Click

        'Initialize a new instance of the data access base class
        Using objAccessDB As New WDABase
            Try
                'Get all Groups in a DataReader object
                objAccessDB.SQL = "usp_SelectGroups"
                objAccessDB.InitializeCommand()
                objAccessDB.OpenConnection()
                objAccessDB.DataReader = objAccessDB.Command.ExecuteReader

                'See if any data exists before continuing
                If objAccessDB.DataReader.HasRows Then

                    'Build an INSERT SQL statement
                    objData.SQL = "INSERT INTO Groups " & _
                        "(GroupID, GroupName, GroupDescription, " & _
                        "LastUpdateDate)" & _
                        "VALUES(?, ?, ?, ?)"

                    'Initialize the Command object
                    objData.InitializeCommand()

                    'Add empty parameters to the Parameters collection
                    objData.AddParameter("GroupID", _
                        Data.OleDb.OleDbType.Char, 36, Nothing)
                    objData.AddParameter("GroupName", _
                        Data.OleDb.OleDbType.VarChar, 50, Nothing)
                    objData.AddParameter("GroupDescription", _
                        Data.OleDb.OleDbType.LongVarChar, 1000, Nothing)
                    objData.AddParameter("LastUpdateDate", _
                        Data.OleDb.OleDbType.Date, 8, Nothing)

                    'Process all rows
                    While objAccessDB.DataReader.Read()

                        'Set the parameter values
                        objData.Command.Parameters("GroupID").Value = _
                            objAccessDB.DataReader.Item("GroupID").ToString
                        objData.Command.Parameters("GroupName").Value = _
                            objAccessDB.DataReader.Item("GroupName")
                        objData.Command.Parameters("GroupDescription").Siz e = _
                            objAccessDB.DataReader.Item( _
                            "GroupDescription").ToString.Length
                        objData.Command.Parameters("GroupDescription").Val ue = _
                            objAccessDB.DataReader.Item("GroupDescription")
                        objData.Command.Parameters("LastUpdateDate").Value = _
                            objAccessDB.DataReader.Item("LastUpdateDate")

                        'Execute the INSERT statement
                        objData.Command.ExecuteNonQuery()

                    End While

                End If

                'Close the DataReader
                objAccessDB.DataReader.Close()

                'Close the database connection
                objAccessDB.CloseConnection()

                'Set the status message
                lblGroups.Text = "Data successfully migrated"
            Catch ExceptionErr As Exception
                MessageBox.Show(ExceptionErr.Message)
            Finally
                'Cleanup
                objData.Command.Dispose()
                objData.Command = Nothing
            End Try
        End Using

    End Sub
    Private Sub btnProjects_Click(ByVal sender As Object, _
        ByVal e As System.EventArgs) Handles btnProjects.Click

        'Initialize a new instance of the data access base class
        Using objAccessDB As New WDABase
            Try
                'Get all Projects in a DataReader object
                objAccessDB.SQL = "usp_SelectProjects"
                objAccessDB.InitializeCommand()
                objAccessDB.OpenConnection()
                objAccessDB.DataReader = objAccessDB.Command.ExecuteReader

                'See if any data exists before continuing
                If objAccessDB.DataReader.HasRows Then

                    'Build an INSERT SQL statement
                    objData.SQL = "INSERT INTO Projects " & _
                        "(ProjectID, ProjectName, ProjectDescription, " & _
                        "SequenceNumber, LastUpdateDate) " & _
                        "VALUES(?, ?, ?, ?, ?)"

                    'Initialize the Command object
                    objData.InitializeCommand()

                    'Add empty parameters to the Parameters collection
                    objData.AddParameter("ProjectID", _
                        Data.OleDb.OleDbType.Char, 36, Nothing)
                    objData.AddParameter("ProjectName", _
                        Data.OleDb.OleDbType.VarChar, 50, Nothing)
                    objData.AddParameter("ProjectDescription", _
                        Data.OleDb.OleDbType.LongVarChar, 1000, Nothing)
                    objData.AddParameter("SequenceNumber", _
                        Data.OleDb.OleDbType.UnsignedTinyInt, 1, Nothing)
                    objData.AddParameter("LastUpdateDate", _
                        Data.OleDb.OleDbType.Date, 8, Nothing)

                    'Process all rows
                    While objAccessDB.DataReader.Read()

                        'Set the parameter values
                        objData.Command.Parameters("ProjectID").Value = _
                            objAccessDB.DataReader.Item("ProjectID").ToString
                        objData.Command.Parameters("ProjectName").Value = _
                            objAccessDB.DataReader.Item("ProjectName")
                        objData.Command.Parameters("ProjectDescription").S ize = _
                            objAccessDB.DataReader.Item( _
                            "ProjectDescription").ToString.Length
                        objData.Command.Parameters("ProjectDescription").V alue = _
                            objAccessDB.DataReader.Item("ProjectDescription")
                        objData.Command.Parameters("SequenceNumber").Value = _
                            objAccessDB.DataReader.Item("SequenceNumber")
                        objData.Command.Parameters("LastUpdateDate").Value = _
                            objAccessDB.DataReader.Item("LastUpdateDate")

                        'Execute the INSERT statement
                        objData.Command.ExecuteNonQuery()

                    End While

                End If

                'Close the DataReader
                objAccessDB.DataReader.Close()

                'Close the database connection
                objAccessDB.CloseConnection()

                'Set the status message
                lblProjects.Text = "Data successfully migrated"
            Catch ExceptionErr As Exception
                MessageBox.Show(ExceptionErr.Message)
            Finally
                'Cleanup
                objData.Command.Dispose()
                objData.Command = Nothing
            End Try
        End Using
    End Sub
End Class



Richard A. LaFrance





Similar Threads
Thread Thread Starter Forum Replies Last Post
Error: Invalid postback or call back argument kalyanykk ASP.NET 2.0 Basics 0 August 26th, 2008 06:03 AM
compile error: argument not optional loverman210 Beginning VB 6 3 June 8th, 2007 07:59 AM
VB Error: BC30455 brite ASP.NET 1.0 and 1.1 Basics 0 March 28th, 2007 02:14 PM
Error: Argument not optional toshesh Excel VBA 10 January 20th, 2006 10:57 AM





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