llmclaughlin
Programmer
I create a datatable with a primary key and it works until I do the sorting from the dataview and refill the datatable. At which time I start getting message when I try to make changes to the table that Table does not have a primary key.
Setting primary key
mdtComp = New Data.DataTable
Dim dsProcs As Data.DataSet = New Data.DataSet
With dsProcs
.Tables.Add("Comp")
.Tables("Comp").Columns.Add("Model", System.Type.GetType("System.String"))
End With
columns(0) = dsProcs.Tables("Comp").Columns("Model")
dsProcs.Tables("Comp").PrimaryKey = columns
mdtComp = dsProcs.Tables("Comp")
mdvComp = New Data.DataView(mdtComp)
After I do the below I no longer have the primary key.
If Trim(txtFilter.Text) <> "" Then
iGot = txtFilter.Text.IndexOf("%")
If iGot > 0 Then
strSQL = "Model Like '" + txtFilter.Text + "'"
Else
strSQL = "Model Like '" + txtFilter.Text + "%'"
End If
Else
strSQL = "Model%"
End If
mdvComp.RowFilter = strSQL
mdtComp = mdvComp.ToTable
dgdComp.Rows.Clear()
LoadGrid()
Any suggestions on how reset primary key?
Thanks
Louie
Setting primary key
mdtComp = New Data.DataTable
Dim dsProcs As Data.DataSet = New Data.DataSet
With dsProcs
.Tables.Add("Comp")
.Tables("Comp").Columns.Add("Model", System.Type.GetType("System.String"))
End With
columns(0) = dsProcs.Tables("Comp").Columns("Model")
dsProcs.Tables("Comp").PrimaryKey = columns
mdtComp = dsProcs.Tables("Comp")
mdvComp = New Data.DataView(mdtComp)
After I do the below I no longer have the primary key.
If Trim(txtFilter.Text) <> "" Then
iGot = txtFilter.Text.IndexOf("%")
If iGot > 0 Then
strSQL = "Model Like '" + txtFilter.Text + "'"
Else
strSQL = "Model Like '" + txtFilter.Text + "%'"
End If
Else
strSQL = "Model%"
End If
mdvComp.RowFilter = strSQL
mdtComp = mdvComp.ToTable
dgdComp.Rows.Clear()
LoadGrid()
Any suggestions on how reset primary key?
Thanks
Louie