Cannot Update data via DatagridView

M

mk

Hi all,
I am using VS2005. I am using Datagrid view to edit some datas and
update it.
this is what I have bind to Datagridview

SqlAdapter = New SqlDataAdapter()
SqlAdapter.SelectCommand = SqlCmd

Dim Cmd As New SqlCommand("Update Table_xxx Set Remarks=@q1
Where SiNo=@q2", con)
Dim Objparam As SqlParameter
Objparam = Cmd.Parameters.Add("@q1", SqlDbType.VarChar)
Objparam.Direction = ParameterDirection.Input
Objparam.SourceColumn = "Remarks"
Objparam.SourceVersion = DataRowVersion.Current

Objparam = Cmd.Parameters.Add("@q2", SqlDbType.Int)
Objparam.Direction = ParameterDirection.Input
Objparam.SourceColumn = "SiNo"
Objparam.SourceVersion = DataRowVersion.Original

SqlAdapter.UpdateCommand = Cmd
DBGrid1.DataSource = Nothing
DBGrid1.Columns.Clear()
DGridDS.Clear()
SqlAdapter.Fill(DGridDS)
DBGrid1.DataSource = DGridDS.Tables(0)

And my Values updating Process goes here..

If DGridDS.HasChanges Then
Dim TDS As New DataSet
TDS = DGridDS.GetChanges(DataRowState.Modified)
SqlAdapter.Update(TDS)
End If

Everythings goes fine.. but when I try to update the column value.. its
is not updating. when i debug the code i found that the
DGridDS.HasChanges returns false.
but when i try update the columns continually the second,third and so
on.. is updating well
The Problem is when updating the column at first..
I don't know where I am missing the code.
Please help me..
Regards
Muthu Kumaran.D
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top