Hi all
I'm very new to vb.net and ADO.net. I am trying to connect to a mysql database.. i've managed that
Now I'm working on the Update, Delete and Insert commands. I don't want to hard code the parameters for these commands as in all the examples i can find.. ie:
Instead I would like it to read the columns from my dataset and add those as parameters. Has anyone tried to do this?? ie:
This code doesn't work. I need to give the parameter a OleDb.OleDbType argument (
) to specify the datatype of the field. The only datatype I can get out of the dataset is of type
(
). I cannot figure out how to convert
to
.
I must be missing something... it can't be this hard. Unfortunately I can't use the built in CommandBuilder to make all these lovely things for me because i only have the standard edition of vb.net and that doesn't do all the handy stuff for non-microsoft databases. argh.
Any help would be appreciated.
Cheers
nells
I'm very new to vb.net and ADO.net. I am trying to connect to a mysql database.. i've managed that
Code:
selectCMD.Parameters.Add("@Country", OleDbType.VarChar, 15).Value = "UK"
Instead I would like it to read the columns from my dataset and add those as parameters. Has anyone tried to do this?? ie:
Code:
For Each Column In ds.Tables(0).Columns()
ColumnName = Column.ColumnName.ToString
ColumnType = Column.DataType()
da.UpdateCommand.Parameters.Add(ColumnName, ColumnType)
Next Column
This code doesn't work. I need to give the parameter a OleDb.OleDbType argument (
Code:
ColumnType
Code:
System.Type
Code:
Column.DataType()
Code:
System.Type
Code:
OleDb.OleDbType
I must be missing something... it can't be this hard. Unfortunately I can't use the built in CommandBuilder to make all these lovely things for me because i only have the standard edition of vb.net and that doesn't do all the handy stuff for non-microsoft databases. argh.
Any help would be appreciated.
Cheers
nells