I have the below code and I am facing a hard time with the parameter... I get the below error:
the sqlparametercollection only accepts non-null sqlparameter type objects not sqlparameter[] objects
when i insert a msgbox to check the value of param(0).value i get MARC as an example.
Should i create a parameter for every rowData.item(i) too ?
Help needed :) thank you
Dim con As New SqlConnection
Dim cmd As New SqlCommand
con.ConnectionString = "Data Source=USER\SQLEXPRESS;Initial Catalog=DBName;Integrated Security=SSPI"
con.Open()
cmd.Connection = con
Try
Dim InsertCommand As New SqlCommand
Dim param(0) As SqlClient.SqlParameter
param(0) = New SqlParameter("abrev", SqlDbType.VarChar, 50)
param(0).Value = UCase(abrev)
InsertCommand.Parameters.Add(param)
cmd.CommandText = "INSERT INTO allData (ABRV, Times, Num1, Num2, Num3, Num4, Num5) VALUES (param,rowData.Item(0),rowData.Item(1),rowData.Item(2),rowData.Item(3),rowData.Item(4),rowData.Item(5))"
cmd.ExecuteNonQuery()
Catch ex As Exception
MessageBox.Show("Error while inserting record on table..." & ex.Message, "Insert Records")
Finally
con.Close()
End Try