N
Nijazi Halimaji
Hi Newsgroup
I am making a selection with a ODBC-Dataadapter into a Dataset. Then I
create Parameters for Updating the Data with Dataadapter.
When I create the Parameters then I cannot update because I have set the
value of the parameters a fixes value...
My question now is: How must the parameters look like to be connected to the
dataset for updating? This will mean when the dataadapter.update(Dataset) is
executed then the parameters must be dynamic from the Dataset.
Here is my code for better understanding (Please read my Remarks i made here
for understanding):
dim DBC_Command as New OdbcCommand("")
dim ODBC_Connection as New OdbcConnection("")
ODBC_Connection.ConnectionString = "DSN=Muschi2;"
dim ODBC_Adapter as New OdbcDataAdapter("SELECT SMSVersNr, NatelNr,
NatelRueckNr, Nachricht, AnzahlVersuche FROM SMSVers
ODBC_Adapter.SelectCommand.Connection = ODBC_Connection
ODBC_Adapter.UpdateCommand = ODBC_Command
ODBC_Adapter.UpdateCommand.CommandText = "UPDATE SMSVers set VersandDatum =
?, VersandZeit = ?, AnzahlVersuche = ? where SMSVersNr = ?"
ODBC_Adapter.UpdateCommand.Connection = ODBC_Connection
ODBC_Adapter.UpdateCommand.Parameters.Add("@VersandDatum",
OdbcType.DateTime)
ODBC_Adapter.UpdateCommand.Parameters.Add("@VersandZeit", OdbcType.DateTime)
ODBC_Adapter.UpdateCommand.Parameters.Add("@AnzahlVersuche", OdbcType.Int)
ODBC_Adapter.UpdateCommand.Parameters.Add("@SMSVersNr", OdbcType.Text)
Now I fill the dataset with data and adding 2 colums
Dim tmpds As New DataSet
ODBC_Adapter.Fill(tmpds)
tmpds.Tables(0).Columns.Add("VersandZeit")
tmpds.Tables(0).Columns.Add("VersandDatum")
Now I make changes on my dataset
ds.Tables(0).Rows(2).Item("AnzahlVersuche")= 9
ds.Tables(0).Rows(0).Item("AnzahlVersuche") = 7
ds.Tables(0).Rows(1).Item("AnzahlVersuche") = 5
Now this is where I am making the mistake, because I am Setting the values
of the Parameters to fixed Values
ODBC_Adapter.UpdateCommand.Parameters(0).Value =
myDataSet.Tables(0).Rows(0).Item("VersandDatum")
ODBC_Adapter.UpdateCommand.Parameters(1).Value =
myDataSet.Tables(0).Rows(0).Item("VersandZeit")
ODBC_Adapter.UpdateCommand.Parameters(2).Value =
myDataSet.Tables(0).Rows(0).Item("AnzahlVersuche")
ODBC_Adapter.UpdateCommand.Parameters(3).Value =
myDataSet.Tables(0).Rows(0).Item("SMSVersNr")
ODBC_Adapter.Update(myDataSet)
Is there a possiblity to make this update dynamic?
Thanks alot
Nijazi Halimaji
I am making a selection with a ODBC-Dataadapter into a Dataset. Then I
create Parameters for Updating the Data with Dataadapter.
When I create the Parameters then I cannot update because I have set the
value of the parameters a fixes value...
My question now is: How must the parameters look like to be connected to the
dataset for updating? This will mean when the dataadapter.update(Dataset) is
executed then the parameters must be dynamic from the Dataset.
Here is my code for better understanding (Please read my Remarks i made here
for understanding):
dim DBC_Command as New OdbcCommand("")
dim ODBC_Connection as New OdbcConnection("")
ODBC_Connection.ConnectionString = "DSN=Muschi2;"
dim ODBC_Adapter as New OdbcDataAdapter("SELECT SMSVersNr, NatelNr,
NatelRueckNr, Nachricht, AnzahlVersuche FROM SMSVers
ODBC_Adapter.SelectCommand.Connection = ODBC_Connection
ODBC_Adapter.UpdateCommand = ODBC_Command
ODBC_Adapter.UpdateCommand.CommandText = "UPDATE SMSVers set VersandDatum =
?, VersandZeit = ?, AnzahlVersuche = ? where SMSVersNr = ?"
ODBC_Adapter.UpdateCommand.Connection = ODBC_Connection
ODBC_Adapter.UpdateCommand.Parameters.Add("@VersandDatum",
OdbcType.DateTime)
ODBC_Adapter.UpdateCommand.Parameters.Add("@VersandZeit", OdbcType.DateTime)
ODBC_Adapter.UpdateCommand.Parameters.Add("@AnzahlVersuche", OdbcType.Int)
ODBC_Adapter.UpdateCommand.Parameters.Add("@SMSVersNr", OdbcType.Text)
Now I fill the dataset with data and adding 2 colums
Dim tmpds As New DataSet
ODBC_Adapter.Fill(tmpds)
tmpds.Tables(0).Columns.Add("VersandZeit")
tmpds.Tables(0).Columns.Add("VersandDatum")
Now I make changes on my dataset
ds.Tables(0).Rows(2).Item("AnzahlVersuche")= 9
ds.Tables(0).Rows(0).Item("AnzahlVersuche") = 7
ds.Tables(0).Rows(1).Item("AnzahlVersuche") = 5
Now this is where I am making the mistake, because I am Setting the values
of the Parameters to fixed Values
ODBC_Adapter.UpdateCommand.Parameters(0).Value =
myDataSet.Tables(0).Rows(0).Item("VersandDatum")
ODBC_Adapter.UpdateCommand.Parameters(1).Value =
myDataSet.Tables(0).Rows(0).Item("VersandZeit")
ODBC_Adapter.UpdateCommand.Parameters(2).Value =
myDataSet.Tables(0).Rows(0).Item("AnzahlVersuche")
ODBC_Adapter.UpdateCommand.Parameters(3).Value =
myDataSet.Tables(0).Rows(0).Item("SMSVersNr")
ODBC_Adapter.Update(myDataSet)
Is there a possiblity to make this update dynamic?
Thanks alot
Nijazi Halimaji