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
|