I use DatagridTableStyle to display data from table
WF_Carrier_FreightChart. USers than can add/delete/edit rows in the
Datagrid.
Since the Datagrid's datasource "dCarrierFreight" is just a copy/view of the
table (dataset dFreight.tables(0) ), I need to update the original table to
reflect multiple changes in the Datagrid.
Your help is greatly appreciated.
Bill
-------------
Private Function showFreightDetail(ByVal rowID As Integer) As Integer
Dim dSQL As String
Dim dr As DataRow
Dim dvRow As DataRowView
dr = dMain.Tables(0).Rows(rowID)
'txtBolID.Refresh()
txtTest.Text = dr.Item("CarrierName")
dSQL = "SELECT CarrierID, FreightLinkID, Mile_From, Mile_To, WF_GasFreight,
WF_DslFreight, "
dSQL += " JACO_GasFreight, JACO_DslFreight FROM WF_Carrier_FreightChart "
dSQL += " WHERE carrierID = " & "'" & Trim(dr.Item("Carrierid")) & "' "
dSQL += " ORDER By CarrierID, Mile_From, Mile_to "
Try
DataGrid2.Enabled = True
Dim iType As Integer = 1
Dim iSort As Integer
dCarrierFreight = New DataSet("mpCarrier")
Dim tFreight As DataTable
tFreight = New DataTable("dpFreightTable")
Dim cRowID As DataColumn
cRowID = New DataColumn("rowID")
Dim cCarrierID As DataColumn
cCarrierID = New DataColumn("CarrierID")
Dim cMileFrom As DataColumn
cMileFrom = New DataColumn("MileFrom")
Dim cMileTo As DataColumn
cMileTo = New DataColumn("MileTo")
Dim cWFGas As DataColumn
cWFGas = New DataColumn("WFGas")
Dim cWFDsl As DataColumn
cWFDsl = New DataColumn("WFDsl")
Dim cJAGas As DataColumn
cJAGas = New DataColumn("JAGas")
Dim cJADsl As DataColumn
cJADsl = New DataColumn("JADsl")
tFreight.Columns.Add(cRowID)
tFreight.Columns.Add(cCarrierID)
tFreight.Columns.Add(cMileFrom)
tFreight.Columns.Add(cMileTo)
tFreight.Columns.Add(cWFGas)
tFreight.Columns.Add(cWFDsl)
tFreight.Columns.Add(cJAGas)
tFreight.Columns.Add(cjaDsl)
dCarrierFreight.Tables.Add(tFreight)
dFreight = MAPPOINTDataBoss.dWFIRecView(dSQL)
If dFreight.Tables(0).Rows.Count = 0 Then
Beep()
Call DisplayStatus("No records found! Nothing to display.", "red")
Else
End If
Dim dFreightRow, dCarrierFreightRow As DataRow
For Each dFreightRow In dFreight.Tables(0).Rows
dCarrierFreightRow = tFreight.NewRow
dCarrierFreightRow("rowID") = iType.ToString
dCarrierFreightRow("CarrierID") = dFreightRow.Item("CarrierID")
dCarrierFreightRow("Milefrom") = dFreightRow.Item("Mile_From")
dCarrierFreightRow("Mileto") = dFreightRow.Item("Mile_To")
dCarrierFreightRow("WFGas") = dFreightRow.Item("WF_GasFreight")
dCarrierFreightRow("WFDsl") = dFreightRow.Item("WF_DslFreight")
dCarrierFreightRow("JAGas") = dFreightRow.Item("JACO_GasFreight")
dCarrierFreightRow("JADsl") = dFreightRow.Item("JACO_DslFreight")
tFreight.Rows.Add(dCarrierFreightRow)
Next
' Datagrid table style setup
Dim ts2 As DataGridTableStyle
ts2 = New DataGridTableStyle
ts2.MappingName = "dpFreightTable"
ts2.AlternatingBackColor = Color.Aqua
ts2.AllowSorting = False
Dim txtCol As DataGridTextBoxColumn
txtCol = New DataGridTextBoxColumn
txtCol.MappingName = "CarrierID"
txtCol.HeaderText = "CarrierID"
txtCol.ReadOnly = True
txtCol.Width = 40
txtCol = New DataGridTextBoxColumn
txtCol.MappingName = "MileFrom"
txtCol.HeaderText = "From"
txtCol.Width = 50
ts2.GridColumnStyles.Add(txtCol)
txtCol = New DataGridTextBoxColumn
txtCol.MappingName = "MileTo"
txtCol.HeaderText = "To"
txtCol.Width = 50
ts2.GridColumnStyles.Add(txtCol)
txtCol = New DataGridTextBoxColumn
txtCol.MappingName = "WFGas"
txtCol.HeaderText = "WF Gas"
txtCol.Width = 60
ts2.GridColumnStyles.Add(txtCol)
txtCol = New DataGridTextBoxColumn
txtCol.MappingName = "WFDsl"
txtCol.HeaderText = "WF Dsl"
txtCol.Width = 60
ts2.GridColumnStyles.Add(txtCol)
txtCol = New DataGridTextBoxColumn
txtCol.MappingName = "JAGas"
txtCol.HeaderText = "Jaco Gas"
txtCol.Width = 60
ts2.GridColumnStyles.Add(txtCol)
txtCol = New DataGridTextBoxColumn
txtCol.MappingName = "JADsl"
txtCol.HeaderText = "Jaco Dsl"
txtCol.Width = 60
ts2.GridColumnStyles.Add(txtCol)
DataGrid2.TableStyles.Clear()
DataGrid2.TableStyles.Add(ts2)
Me.DataGrid2.DataSource = dCarrierFreight
Me.DataGrid2.DataMember = "dpFreighttable"
Catch ex As Exception
Catch ex As SqlException
End Try
End Function 6 3463
Bill,
A view is not copy
a
Dim a as datatable = myDataTable is not a copy,
It are both other references to the same table
So how do you copy your table.
Cor
"Bill nguyen" <bi*****************@jaco.com> schreef in bericht
news:e4**************@TK2MSFTNGP12.phx.gbl... I use DatagridTableStyle to display data from table WF_Carrier_FreightChart. USers than can add/delete/edit rows in the Datagrid. Since the Datagrid's datasource "dCarrierFreight" is just a copy/view of the table (dataset dFreight.tables(0) ), I need to update the original table to reflect multiple changes in the Datagrid.
Your help is greatly appreciated.
Bill
-------------
Private Function showFreightDetail(ByVal rowID As Integer) As Integer Dim dSQL As String Dim dr As DataRow
Dim dvRow As DataRowView
dr = dMain.Tables(0).Rows(rowID)
'txtBolID.Refresh()
txtTest.Text = dr.Item("CarrierName")
dSQL = "SELECT CarrierID, FreightLinkID, Mile_From, Mile_To, WF_GasFreight, WF_DslFreight, "
dSQL += " JACO_GasFreight, JACO_DslFreight FROM WF_Carrier_FreightChart "
dSQL += " WHERE carrierID = " & "'" & Trim(dr.Item("Carrierid")) & "' "
dSQL += " ORDER By CarrierID, Mile_From, Mile_to "
Try
DataGrid2.Enabled = True
Dim iType As Integer = 1
Dim iSort As Integer dCarrierFreight = New DataSet("mpCarrier")
Dim tFreight As DataTable
tFreight = New DataTable("dpFreightTable")
Dim cRowID As DataColumn
cRowID = New DataColumn("rowID")
Dim cCarrierID As DataColumn
cCarrierID = New DataColumn("CarrierID")
Dim cMileFrom As DataColumn
cMileFrom = New DataColumn("MileFrom")
Dim cMileTo As DataColumn
cMileTo = New DataColumn("MileTo")
Dim cWFGas As DataColumn
cWFGas = New DataColumn("WFGas")
Dim cWFDsl As DataColumn
cWFDsl = New DataColumn("WFDsl")
Dim cJAGas As DataColumn
cJAGas = New DataColumn("JAGas")
Dim cJADsl As DataColumn
cJADsl = New DataColumn("JADsl")
tFreight.Columns.Add(cRowID)
tFreight.Columns.Add(cCarrierID)
tFreight.Columns.Add(cMileFrom)
tFreight.Columns.Add(cMileTo)
tFreight.Columns.Add(cWFGas)
tFreight.Columns.Add(cWFDsl)
tFreight.Columns.Add(cJAGas)
tFreight.Columns.Add(cjaDsl)
dCarrierFreight.Tables.Add(tFreight)
dFreight = MAPPOINTDataBoss.dWFIRecView(dSQL)
If dFreight.Tables(0).Rows.Count = 0 Then
Beep()
Call DisplayStatus("No records found! Nothing to display.", "red")
Else
End If
Dim dFreightRow, dCarrierFreightRow As DataRow
For Each dFreightRow In dFreight.Tables(0).Rows
dCarrierFreightRow = tFreight.NewRow
dCarrierFreightRow("rowID") = iType.ToString
dCarrierFreightRow("CarrierID") = dFreightRow.Item("CarrierID")
dCarrierFreightRow("Milefrom") = dFreightRow.Item("Mile_From")
dCarrierFreightRow("Mileto") = dFreightRow.Item("Mile_To")
dCarrierFreightRow("WFGas") = dFreightRow.Item("WF_GasFreight")
dCarrierFreightRow("WFDsl") = dFreightRow.Item("WF_DslFreight")
dCarrierFreightRow("JAGas") = dFreightRow.Item("JACO_GasFreight")
dCarrierFreightRow("JADsl") = dFreightRow.Item("JACO_DslFreight")
tFreight.Rows.Add(dCarrierFreightRow) Next ' Datagrid table style setup
Dim ts2 As DataGridTableStyle
ts2 = New DataGridTableStyle
ts2.MappingName = "dpFreightTable"
ts2.AlternatingBackColor = Color.Aqua
ts2.AllowSorting = False
Dim txtCol As DataGridTextBoxColumn
txtCol = New DataGridTextBoxColumn
txtCol.MappingName = "CarrierID"
txtCol.HeaderText = "CarrierID"
txtCol.ReadOnly = True
txtCol.Width = 40 txtCol = New DataGridTextBoxColumn
txtCol.MappingName = "MileFrom"
txtCol.HeaderText = "From"
txtCol.Width = 50
ts2.GridColumnStyles.Add(txtCol)
txtCol = New DataGridTextBoxColumn
txtCol.MappingName = "MileTo"
txtCol.HeaderText = "To"
txtCol.Width = 50 ts2.GridColumnStyles.Add(txtCol)
txtCol = New DataGridTextBoxColumn
txtCol.MappingName = "WFGas"
txtCol.HeaderText = "WF Gas"
txtCol.Width = 60
ts2.GridColumnStyles.Add(txtCol) txtCol = New DataGridTextBoxColumn
txtCol.MappingName = "WFDsl"
txtCol.HeaderText = "WF Dsl"
txtCol.Width = 60
ts2.GridColumnStyles.Add(txtCol) txtCol = New DataGridTextBoxColumn
txtCol.MappingName = "JAGas"
txtCol.HeaderText = "Jaco Gas"
txtCol.Width = 60
ts2.GridColumnStyles.Add(txtCol)
txtCol = New DataGridTextBoxColumn
txtCol.MappingName = "JADsl"
txtCol.HeaderText = "Jaco Dsl"
txtCol.Width = 60
ts2.GridColumnStyles.Add(txtCol) DataGrid2.TableStyles.Clear()
DataGrid2.TableStyles.Add(ts2) Me.DataGrid2.DataSource = dCarrierFreight
Me.DataGrid2.DataMember = "dpFreighttable" Catch ex As Exception
Catch ex As SqlException
End Try
End Function
Cor;
Providing the problem, can you helo show me a solution?
Thanks
Bill
"Cor Ligthert [MVP]" <no************@planet.nl> wrote in message
news:OP**************@TK2MSFTNGP11.phx.gbl... Bill,
A view is not copy a Dim a as datatable = myDataTable is not a copy,
It are both other references to the same table
So how do you copy your table.
Cor
"Bill nguyen" <bi*****************@jaco.com> schreef in bericht news:e4**************@TK2MSFTNGP12.phx.gbl...I use DatagridTableStyle to display data from table WF_Carrier_FreightChart. USers than can add/delete/edit rows in the Datagrid. Since the Datagrid's datasource "dCarrierFreight" is just a copy/view of the table (dataset dFreight.tables(0) ), I need to update the original table to reflect multiple changes in the Datagrid.
Your help is greatly appreciated.
Bill
-------------
Private Function showFreightDetail(ByVal rowID As Integer) As Integer Dim dSQL As String Dim dr As DataRow
Dim dvRow As DataRowView
dr = dMain.Tables(0).Rows(rowID)
'txtBolID.Refresh()
txtTest.Text = dr.Item("CarrierName")
dSQL = "SELECT CarrierID, FreightLinkID, Mile_From, Mile_To, WF_GasFreight, WF_DslFreight, "
dSQL += " JACO_GasFreight, JACO_DslFreight FROM WF_Carrier_FreightChart "
dSQL += " WHERE carrierID = " & "'" & Trim(dr.Item("Carrierid")) & "' "
dSQL += " ORDER By CarrierID, Mile_From, Mile_to "
Try
DataGrid2.Enabled = True
Dim iType As Integer = 1
Dim iSort As Integer dCarrierFreight = New DataSet("mpCarrier")
Dim tFreight As DataTable
tFreight = New DataTable("dpFreightTable")
Dim cRowID As DataColumn
cRowID = New DataColumn("rowID")
Dim cCarrierID As DataColumn
cCarrierID = New DataColumn("CarrierID")
Dim cMileFrom As DataColumn
cMileFrom = New DataColumn("MileFrom")
Dim cMileTo As DataColumn
cMileTo = New DataColumn("MileTo")
Dim cWFGas As DataColumn
cWFGas = New DataColumn("WFGas")
Dim cWFDsl As DataColumn
cWFDsl = New DataColumn("WFDsl")
Dim cJAGas As DataColumn
cJAGas = New DataColumn("JAGas")
Dim cJADsl As DataColumn
cJADsl = New DataColumn("JADsl")
tFreight.Columns.Add(cRowID)
tFreight.Columns.Add(cCarrierID)
tFreight.Columns.Add(cMileFrom)
tFreight.Columns.Add(cMileTo)
tFreight.Columns.Add(cWFGas)
tFreight.Columns.Add(cWFDsl)
tFreight.Columns.Add(cJAGas)
tFreight.Columns.Add(cjaDsl)
dCarrierFreight.Tables.Add(tFreight)
dFreight = MAPPOINTDataBoss.dWFIRecView(dSQL)
If dFreight.Tables(0).Rows.Count = 0 Then
Beep()
Call DisplayStatus("No records found! Nothing to display.", "red")
Else
End If
Dim dFreightRow, dCarrierFreightRow As DataRow
For Each dFreightRow In dFreight.Tables(0).Rows
dCarrierFreightRow = tFreight.NewRow
dCarrierFreightRow("rowID") = iType.ToString
dCarrierFreightRow("CarrierID") = dFreightRow.Item("CarrierID")
dCarrierFreightRow("Milefrom") = dFreightRow.Item("Mile_From")
dCarrierFreightRow("Mileto") = dFreightRow.Item("Mile_To")
dCarrierFreightRow("WFGas") = dFreightRow.Item("WF_GasFreight")
dCarrierFreightRow("WFDsl") = dFreightRow.Item("WF_DslFreight")
dCarrierFreightRow("JAGas") = dFreightRow.Item("JACO_GasFreight")
dCarrierFreightRow("JADsl") = dFreightRow.Item("JACO_DslFreight")
tFreight.Rows.Add(dCarrierFreightRow) Next ' Datagrid table style setup
Dim ts2 As DataGridTableStyle
ts2 = New DataGridTableStyle
ts2.MappingName = "dpFreightTable"
ts2.AlternatingBackColor = Color.Aqua
ts2.AllowSorting = False
Dim txtCol As DataGridTextBoxColumn
txtCol = New DataGridTextBoxColumn
txtCol.MappingName = "CarrierID"
txtCol.HeaderText = "CarrierID"
txtCol.ReadOnly = True
txtCol.Width = 40 txtCol = New DataGridTextBoxColumn
txtCol.MappingName = "MileFrom"
txtCol.HeaderText = "From"
txtCol.Width = 50
ts2.GridColumnStyles.Add(txtCol)
txtCol = New DataGridTextBoxColumn
txtCol.MappingName = "MileTo"
txtCol.HeaderText = "To"
txtCol.Width = 50 ts2.GridColumnStyles.Add(txtCol)
txtCol = New DataGridTextBoxColumn
txtCol.MappingName = "WFGas"
txtCol.HeaderText = "WF Gas"
txtCol.Width = 60
ts2.GridColumnStyles.Add(txtCol) txtCol = New DataGridTextBoxColumn
txtCol.MappingName = "WFDsl"
txtCol.HeaderText = "WF Dsl"
txtCol.Width = 60
ts2.GridColumnStyles.Add(txtCol) txtCol = New DataGridTextBoxColumn
txtCol.MappingName = "JAGas"
txtCol.HeaderText = "Jaco Gas"
txtCol.Width = 60
ts2.GridColumnStyles.Add(txtCol)
txtCol = New DataGridTextBoxColumn
txtCol.MappingName = "JADsl"
txtCol.HeaderText = "Jaco Dsl"
txtCol.Width = 60
ts2.GridColumnStyles.Add(txtCol) DataGrid2.TableStyles.Clear()
DataGrid2.TableStyles.Add(ts2) Me.DataGrid2.DataSource = dCarrierFreight
Me.DataGrid2.DataMember = "dpFreighttable" Catch ex As Exception
Catch ex As SqlException
End Try
End Function
Bill,
In the way you tell it, than your datasource is the original table and you
can use that to update, however it can as well be.
mynewtable as datatable = myoldtable.copy
Than you can use mynewtable to update and than you have to decide if you
fill the myoldtable again or merge the mynewtable in it.
It is not an abc sample, so again, tell us first how you copy that table.
Cor
In the original post I included the codes.
Bill
"Cor Ligthert [MVP]" <no************@planet.nl> wrote in message
news:eB**************@TK2MSFTNGP14.phx.gbl... Bill,
In the way you tell it, than your datasource is the original table and you can use that to update, however it can as well be.
mynewtable as datatable = myoldtable.copy
Than you can use mynewtable to update and than you have to decide if you fill the myoldtable again or merge the mynewtable in it.
It is not an abc sample, so again, tell us first how you copy that table.
Cor
Bill,
You are using a shallow copy, what is very hard to manage. It is a copy of
the references pointing to the original objects.
For a DataTable something without sence. Why are you doing that, while the
datatable has so many other posibilities.
Cor
What's the best / better way to handle batch update in this case, please?
Thanks
Bill
"Cor Ligthert [MVP]" <no************@planet.nl> wrote in message
news:uZ**************@TK2MSFTNGP10.phx.gbl... Bill,
You are using a shallow copy, what is very hard to manage. It is a copy of the references pointing to the original objects.
For a DataTable something without sence. Why are you doing that, while the datatable has so many other posibilities.
Cor This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Randy |
last post by:
Hello All,
I'm trying to discover the best way to handle the situation where you have a
datagrid in your app and someone changes a cell but doesn't leave that cell
(so there's the little pencil...
|
by: Larry Woods |
last post by:
I have a datagrid that is carrying all fields of a record...except one. Now
I want to update the underlying database via a dataadapter. The update is
working but the field that is "left out" is...
|
by: mursyidatun ismail |
last post by:
Dear all,
database use: Ms Access.
platform: .Net
i'm trying to update a record/records in a table called t_doctors by
clicking da edit link provided in the database.
when i ran through da...
|
by: Stephen Plotnick |
last post by:
I'm very new to VB.NET 2003
Here is what I have accomplished:
MainSelectForm - Selects an item
In a public class I pass a DataViewRow to
ItemInformation1 Form
ItemInformation2 Form
|
by: rockdale |
last post by:
Hi,
I have a web page which let user data enter employee working hours. I
used datagrid to list all the employee and templateColumn to format the
workhours column to textbox for data entry. And...
|
by: Sharon |
last post by:
Hello All,
Is it possible to update Sql Table through DataGrid. I have a DataGrid
which is being populated through a stored procedure, all i wanted to do
is to update one field...
|
by: shookim |
last post by:
I don't care how one suggests I do it, but I've been searching for days
on how to implement this concept. I'm trying to use some kind of grid
control (doesn't have to be a grid control, whatever...
|
by: cedgell |
last post by:
Is it possible to create a batch file of a sql script that would allow end user to update a single field of a table?
For example, a number field is populated but needs to be updated on a daily basis...
|
by: bravo |
last post by:
hi
using mysql 4.1 i wish to update records using batch update but for a batch of 100, records and table having only 5000 records execution time is approx 2.4 sec i want to know whether this time...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |