H
Houssem12
Guest
HI everyone
i have a hard time work with duplicated value in datagridview and in database
when i want to make update query i can't differe with the first and second value for the specific value
for the unique key value from database i haven't any idea how to get it from datagridview
i have only some column to work with
this is the column i want to be updated and use only first column wich is 'Numero' and 2nd 'CodeArticle' to target the specifc row in database
the table in database here is
For i = 0 To DataGridView1.Rows.Count - 1
'this is to get data from database and fill it to table(qqs23)'
Dim usb As New SqlCommand("select Numseq from DetailReceptionFrs where Numero='" & TextBox1.Text & "' and Codearticle='" & DataGridView1.Rows(i).Cells(1).Value & "'", cn)
Dim ttt As New SqlDataAdapter(usb)
ttt.Fill(qqs23)
If cn.State = ConnectionState.Open Then
cn.Close()
End If
cn.Open()
'this where the update methode'
Using cmd1 As New SqlCommand("update DetailReceptionFrs set NumeroEnsemble=@NumeroEnsemble,Marge=@Marge where Numero='" & TextBox1.Text & "' and Numseq='" & qqs23.Rows(0).Item("Numseq") & "'", cn)
With cmd1.Parameters
.Add("@NumeroEnsemble", SqlDbType.NVarChar).Value = (DataGridView1.Rows(i).Cells(7).Value)
.Add("@Marge", SqlDbType.NVarChar).Value = (DataGridView1.Rows(i).Cells(8).Value)
End With
cmd1.ExecuteNonQuery()
End Using
Next
this is where my problem i spoke for (where Numero='" & TextBox1.Text & "' and Codearticle='" & DataGridView1.Rows(i).Cells(1).Value & "'
if already exist it will update the first in database not the target one
please help
Continue reading...
i have a hard time work with duplicated value in datagridview and in database
when i want to make update query i can't differe with the first and second value for the specific value
for the unique key value from database i haven't any idea how to get it from datagridview
i have only some column to work with
this is the column i want to be updated and use only first column wich is 'Numero' and 2nd 'CodeArticle' to target the specifc row in database
the table in database here is
For i = 0 To DataGridView1.Rows.Count - 1
'this is to get data from database and fill it to table(qqs23)'
Dim usb As New SqlCommand("select Numseq from DetailReceptionFrs where Numero='" & TextBox1.Text & "' and Codearticle='" & DataGridView1.Rows(i).Cells(1).Value & "'", cn)
Dim ttt As New SqlDataAdapter(usb)
ttt.Fill(qqs23)
If cn.State = ConnectionState.Open Then
cn.Close()
End If
cn.Open()
'this where the update methode'
Using cmd1 As New SqlCommand("update DetailReceptionFrs set NumeroEnsemble=@NumeroEnsemble,Marge=@Marge where Numero='" & TextBox1.Text & "' and Numseq='" & qqs23.Rows(0).Item("Numseq") & "'", cn)
With cmd1.Parameters
.Add("@NumeroEnsemble", SqlDbType.NVarChar).Value = (DataGridView1.Rows(i).Cells(7).Value)
.Add("@Marge", SqlDbType.NVarChar).Value = (DataGridView1.Rows(i).Cells(8).Value)
End With
cmd1.ExecuteNonQuery()
End Using
Next
this is where my problem i spoke for (where Numero='" & TextBox1.Text & "' and Codearticle='" & DataGridView1.Rows(i).Cells(1).Value & "'
if already exist it will update the first in database not the target one
please help
Continue reading...