i update a database with a dataset and a SqlAdapter with success but when i
clear and refill my dataset i always retreive the old values.
I have to wait for 5 seconds to get the corrects values.
' Step one ==update directly the dataset in memory
Dataset.table.item(0)._Date = DateValue
Dataset.table.item(0).Time = TimeValue
Dataset.table.item(0).Tarif = TarifValue
' Step two ==create and exexute a command to update database
Dim command As New SqlClient.SqlCommand
command.CommandType = CommandType.StoredProcedure
command.CommandText = "Proc_console_Update_Date_And_Tarif"
Dim ParameterSysNum As SqlParameter = command.Parameters.Add
("@SysNum", SqlDbType.Int)
ParameterSysNum.Value = Sys_Num_MSP_System
Dim ParameterJobId As SqlParameter =
command.Parameters.Add("@Jobid", SqlDbType.VarChar, 20)
ParameterJobId.Value = Dataset.table.item(0).Job_Id
Dim ParameterJobDefId As SqlParameter =
command.Parameters.Add("@JobDefid", SqlDbType.VarChar, 20)
ParameterJobDefId.Value = Dataset.table.item(0).Job_Def_Id
Dim ParameterDate As SqlParameter =
command.Parameters.Add("@Date", SqlDbType.VarChar, 20)
ParameterDate.Value = TextBoxStampingDate.Text
Dim ParameterTime As SqlParameter =
command.Parameters.Add("@Time", SqlDbType.VarChar, 20)
ParameterTime.Value = TextBoxStampingTime.Text
Dim ParameterTarif As SqlParameter =
command.Parameters.Add("@Tarif", SqlDbType.VarChar, 20)
ParameterTarif.Value = TextBoxStampingTarif.Text
command.CommandTimeout = 10000
command.Connection = conn
conn.Open()
command.ExecuteNonQuery()
' Step three ==create and exexute adapter to refill dataset
Dim command As New SqlClient.SqlCommand
Dim conn As New SqlClient.SqlConnection
conn.ConnectionString = frmPwd.GetStrconnection()
command.CommandType = CommandType.StoredProcedure
command.CommandText = "Proc_Console_Get_Info_Job"
Dim ParameterJobId As SqlParameter =
command.Parameters.Add("@Jobid", SqlDbType.VarChar, 20)
ParameterJobId.Value = DBNull.Value
Dim ParameterSysNum As SqlParameter =
command.Parameters.Add("@SysNum", SqlDbType.Int)
ParameterSysNum.Value = Sys_Num_MSP_System
command.CommandTimeout = 10000
command.Connection = conn
MpAdaptater.SelectCommand = command
' Step four ==clear and refill dataset
Dataset.table.Clear()
MpAdaptater.Fill(Dataset.table)
between 'step two' and 'step three' I have to wait 5 seconds to have get the
corrects values
I have three TextBoxes which are binded to fields [_Date], [Time], [Tarif]
Language VB.NET 2005 with framework 2.0
SqlServer 2000 with last patch
Best regards