3rd time lucky perhaps?
I'm having some difficulty with some code to update an Access DB. I keep getting "Parameter @ParamName has no default value"
Renaming the parameter in both the SQL statement and the parameter.add, moves the error to a different parameter but it never goes away.
Code:
The Datatable being passed in has between 1 and 10 rows and no blank or null fields.Code:Private Function f_Results_to_DB(ByVal dt_Results As DataTable) As Boolean Dim s_CnnStr As String = "PROVIDER=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=\\serverpath\" & _ "Results.mdb;" & _ "Jet OLEDB:Database Password=password;" Dim s_SQLCon As String = "SELECT * FROM tbl_DataAudit" Dim s_SQL As String = "INSERT INTO tbl_DataAudit (OldPath, FileGUID, UserID, DateTimeDone, LoadedResults, SavedResults) " & _ "VALUES " & _ "(@OldPath, @FileGUID, @UserID, @DateTimeDone, @LoadedResults, @SavedResults)" Try Using cnn As New OleDbConnection(s_CnnStr) Using OleAdaptor As New OleDbDataAdapter(s_SQLCon, cnn) Dim insert As New OleDbCommand(s_SQL, cnn) insert.Parameters.Add("@OldPath", OleDbType.VarChar, 255, "OldPath") insert.Parameters.Add("@FileGUID", OleDbType.VarChar, 255, "FileGUID") insert.Parameters.Add("@UserID", OleDbType.VarChar, 255, "UserID") insert.Parameters.Add("@DateTimeDone", OleDbType.VarChar, 255, "DateTimeDone") insert.Parameters.Add("@LoadedResults", OleDbType.VarChar, 255, "LoadedResults") insert.Parameters.Add("@SavedResults", OleDbType.VarChar, 255, "SavedResults") OleAdaptor.InsertCommand = insert OleAdaptor.MissingSchemaAction = MissingSchemaAction.AddWithKey 'Dim ds As New DataSet() Dim table As New DataTable table = dt_Results 'Save the changes. OleAdaptor.Update(table) End Using End Using Return True Catch ex As Exception Return False End Try End Function
I'm stuck. I havn't been able to find a solution that allows me to continue to use a datatable without iterating through it row by row.
Any ideas?
Regards





Reply With Quote
