Thanks for the help!
I use two data adapters; the first is used to great the data grid. After a
record is selected via the DataGrid or a lookup field and button to execute
the value in the field and find the record from a second data adapter that
was greated with a "SELECT *".
Onve I find the DataViewRow within the second data adapter I pass it in the
Public class to all the forms. I can get data to and get back into the
dataviewrow without any incident. I'm assuming that at any point in any of
the screens I could do the update from the DataViewRow (I'd have no idea how
to do this). My goes would be that an "Update" button would reside on each
form and if the users clicks the Update button an UpdateFlag in the Public
CLass would be set.
At that point I want to check the Update Flag and keep going backwards until
I get to the main form and perform an update using the values in the
DataViewRow.
I than stay in the main form and the user can select another item and go
from there.
Steve
Private Sub PopulateStoreGr id()
Dim conn As New
System.Data.Ole Db.OleDbConnect ion("Provider=M icrosoft.Jet.OL EDB.4.0;Data
source=C:\BMAct ivityReporting. mdb;Persist Security Info=False")
Dim sSQL As String = "select BM_NUMBER, STORE_NUMBER, STORE, SHIP_ADDRESS1
as ADDRESS, SHIP_CITY as CITY, SHIP_ST as STATE from BENMOORETABLE"
Dim sSQL2 As String = "select * from BENMOORETABLE"
conn.Open()
Dim da As New System.Data.Ole Db.OleDbDataAda pter(sSQL, conn)
Dim da2 As New System.Data.Ole Db.OleDbDataAda pter(sSQL2, conn)
Try
da.Fill(myDS, "BENMOOR1")
iCount = myDS.Tables("BE NMOOR1").Rows.C ount
da2.Fill(myDS, "BENMOOR2")
myDV = myDS.Tables("BE NMOOR2").Defaul tView
DataGrid1.DataS ource = myDS
DataGrid1.DataM ember = "BENMOOR1"
Dim irow As Integer
Dim icol As Integer
irow = 0
DataGrid1.Selec t(irow)
Dim sStore As String = CType(DataGrid1 .Item(irow, 1), String)
myDV.Sort = "STORE_NUMB ER"
Dim rowIndex As Integer = myDV.Find(sStor e)
Me.LegalName1.T ext = myDV(rowIndex)( "LEGAL_NAME_LIN E1").ToString ()
Me.LegalName2.T ext = myDV(rowIndex)( "LEGAL_NAME_LIN E2").ToString ()
Me.StoreOwner.T ext = myDV(rowIndex)( "STORE_OWNER"). ToString()
Me.PhoneNumber. Text = myDV(rowIndex)( "PHONE_NUMBER") .ToString()
Me.LegalName3.T ext = myDV(rowIndex)( "LEGAL_NAME_LIN E3").ToString ()
Me.LegalName4.T ext = myDV(rowIndex)( "LEGAL_NAME_LIN E4").ToString ()
Me.EMailAddress .Text = myDV(rowIndex)( "E-MAIL_ADDRESS"). ToString()
'UpdateScreen(i row)
Catch ex As Exception
MessageBox.Show ("Failed to connect to data source")
Finally
conn.Close()
End Try
End Sub
Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
myFormLibrary.S toreInformation 1 = Me
myFormLibrary.S toreInformation 2 = Me
myFormLibrary.S toreInformation 4 = Me
myFormLibrary.S toreInformation 4 = Me
myFormLibrary.S toreInformation 5 = Me
myFormLibrary.S toreInformation 6 = Me
myFormLibrary.S toreInformation 7 = Me
PopulateStoreGr id()
'
' Create a Grid Table Style. Map it to the "Customers" Table.
'
Dim aGridTableStyle As New DataGridTableSt yle
aGridTableStyle .MappingName = "BENMOOR1"
'
' Create GridColumnStyle objects for the grid columns
'
Dim aCol1 As New DataGridTextBox Column
Dim aCol2 As New DataGridTextBox Column
Dim aCol3 As New DataGridTextBox Column
Dim aCol4 As New DataGridTextBox Column
Dim aCol5 As New DataGridTextBox Column
Dim aCol6 As New DataGridTextBox Column
'
With aCol1
..HeaderText = "BM#"
..MappingName = "BM_NUMBER"
..Width = 45
..TextBox.Enabl ed = False
End With
'
' Set column 2's caption, width and disable editing.
'
With aCol2
..MappingName = "STORE_NUMB ER"
..HeaderText = "Store#"
..Width = 40
..Alignment = HorizontalAlign ment.Left
..TextBox.Enabl ed = False
End With
With aCol3
..MappingName = "STORE"
..HeaderText = "Store Name"
..Width = 200
..Alignment = HorizontalAlign ment.Left
' .NullText = ""
..TextBox.Enabl ed = False
End With
With aCol4
..MappingName = "ADDRESS"
..HeaderText = "Store Address"
..Width = 200
..Alignment = HorizontalAlign ment.Left
'.NullText = "0"
..TextBox.Enabl ed = False
'.Format = "#0.00"
End With
With aCol5
..MappingName = "CITY"
..HeaderText = "CIty"
..Width = 100
..Alignment = HorizontalAlign ment.Left
'.NullText = "0"
..TextBox.Enabl ed = False
'.Format = "#0.00"
End With
With aCol6
..MappingName = "STATE"
..HeaderText = "St."
..Width = 30
..Alignment = HorizontalAlign ment.Left
'.NullText = "0"
..TextBox.Enabl ed = False
'.Format = "#0.00"
End With
'
' Add the GridColumnStyle s to the DataGrid's Column Styles collection.
'
With aGridTableStyle .GridColumnStyl es
..Add(aCol1)
..Add(aCol2)
..Add(aCol3)
..Add(aCol4)
..Add(aCol5)
..Add(aCol6)
End With
'
' Add the GridColumnStyle s to the aGridTableStyle .
'
DataGrid1.Table Styles.Add(aGri dTableStyle)
End Sub
Private Sub DataGrid1_Doubl eClick(ByVal sender As Object, ByVal e As
System.EventArg s) Handles DataGrid1.Doubl eClick
Dim StoreNo1 As String
Dim Storeno2 As String
Dim checkarea As String
Dim irow As Integer = DataGrid1.Curre ntCell.RowNumbe r
Dim sStore As String = CType(DataGrid1 .Item(irow, 1), String)
myDV.Sort = "STORE_NUMB ER"
Dim rowIndex As Integer = myDV.Find(sStor e)
Dim frminfo As New StoreInformatio n
'Set up values for storeinfor screen
frminfo.LegalNa me1.Text = myDV(rowIndex)( "LEGAL_NAME_LIN E1").ToString ()
frminfo.LegalNa me2.Text = myDV(rowIndex)( "LEGAL_NAME_LIN E2").ToString ()
frminfo.StoreOw ner.Text = myDV(rowIndex)( "STORE_OWNER"). ToString()
frminfo.PhoneNu mber.Text = myDV(rowIndex)( "PHONE_NUMBER") .ToString()
frminfo.LegalNa me3.Text = myDV(rowIndex)( "LEGAL_NAME_LIN E3").ToString ()
frminfo.LegalNa me4.Text = myDV(rowIndex)( "LEGAL_NAME_LIN E4").ToString ()
frminfo.EMailAd dress.Text = myDV(rowIndex)( "E-MAIL_ADDRESS"). ToString()
StoreNo1 = myDV(rowIndex)( "STORE_NUMBER") .ToString()
Storeno2 = myDV(rowIndex)( "PARENT_STORE_N UMBER").ToStrin g()
frminfo.StoreNo .Text = StoreNo1 & " / " & Storeno2
StoreNo1 = myDV(rowIndex)( "BM_NUMBER").To String()
Storeno2 = myDV(rowIndex)( "CURR").ToStrin g()
frminfo.BMNUMBE R.Text = StoreNo1 & " / " & Storeno2
frminfo.MailToN ame.Text = myDV(rowIndex)( "MAIL_NAME").To String()
frminfo.MailToA dd1.Text = myDV(rowIndex)( "MAIL_ADDRESS1" ).ToString()
frminfo.MailToA dd2.Text = myDV(rowIndex)( "MAIL_ADDRESS2" ).ToString()
frminfo.MailToC ity.Text = myDV(rowIndex)( "MAIL_CITY").To String()
frminfo.MailToS tate.Text = myDV(rowIndex)( "MAIL_ST").ToSt ring()
frminfo.MailToZ ip.Text = myDV(rowIndex)( "MAIL_ZIPCODE") .ToString()
frminfo.ShipToN ame.Text = myDV(rowIndex)( "STORE").ToStri ng()
frminfo.ShipToA dd1.Text = myDV(rowIndex)( "SHIP_ADDRESS1" ).ToString()
frminfo.ShipToA dd2.Text = myDV(rowIndex)( "SHIP_ADDRESS2" ).ToString()
frminfo.ShipToC ity.Text = myDV(rowIndex)( "SHIP_CITY").To String()
frminfo.ShipToC ounty.Text = myDV(rowIndex)( "COUNTY").ToStr ing()
frminfo.ShipToS tate.Text = myDV(rowIndex)( "SHIP_ST").ToSt ring()
frminfo.ShipToZ ip.Text = myDV(rowIndex)( "MAIL_ZIPCODE") .ToString()
frminfo.Supplie rRepTop1.Text = myDV(rowIndex)( "PAINT_TERRITOR Y_MANAGE_
NAME").ToString ()
frminfo.Supplie rRepTop2.Text = myDV(rowIndex)( "REGIONAL_MANAG ER").ToString ()
frminfo.Supplie rRepTop3.Text =
myDV(rowIndex)( "RETAIL_BUSINES _MANAGER").ToSt ring()
frminfo.Supplie rRepTop4.Text =
myDV(rowIndex)( "RETAIL_DEVELOP MEN_MANAGER1"). ToString()
frminfo.Supplie rRepTop5.Text = myDV(rowIndex)( "RETAI_DEVELOPM ENT_MANAGE
2").ToString ()
Dim frminfo1 As New StoreInformatio n1
'Set up values for storeinform1 screen
frminfo1.LegalN ame1.Text = myDV(rowIndex)( "LEGAL_NAME_LIN E1").ToString ()
frminfo1.LegalN ame2.Text = myDV(rowIndex)( "LEGAL_NAME_LIN E2").ToString ()
frminfo1.StoreO wner.Text = myDV(rowIndex)( "STORE_OWNER"). ToString()
frminfo1.PhoneN umber.Text = myDV(rowIndex)( "PHONE_NUMBER") .ToString()
frminfo1.LegalN ame3.Text = myDV(rowIndex)( "LEGAL_NAME_LIN E3").ToString ()
frminfo1.LegalN ame4.Text = myDV(rowIndex)( "LEGAL_NAME_LIN E4").ToString ()
frminfo1.EMailA ddress.Text = myDV(rowIndex)( "E-MAIL_ADDRESS"). ToString()
StoreNo1 = myDV(rowIndex)( "STORE_NUMBER") .ToString()
Storeno2 = myDV(rowIndex)( "PARENT_STORE_N UMBER").ToStrin g()
frminfo1.StoreN o.Text = StoreNo1 & " / " & Storeno2
StoreNo1 = myDV(rowIndex)( "BM_NUMBER").To String()
Storeno2 = myDV(rowIndex)( "CURR").ToStrin g()
frminfo1.BMNUMB ER.Text = StoreNo1 & " / " & Storeno2
frminfo1.Approv alDate.Text = myDV(rowIndex)( "APPROVAL_DATE" ).ToString()
frminfo1.Vision 21Rank.Text = myDV(rowIndex)( "VISION21_RANK" ).ToString()
frminfo1.NoBran ches.Text = myDV(rowIndex)( "NUMBER_BRANCHE S").ToString ()
frminfo1.Comput erType.Text = myDV(rowIndex)( "COMPUTER_TYPE" ).ToString()
frminfo1.CYL.Te xt = myDV(rowIndex)( "CYL").ToString ()
frminfo1.TotBld gSF.Text = myDV(rowIndex)( "TOTAL_BLDG_SF" ).ToString()
frminfo1.Retail HDWSF.Text = myDV(rowIndex)( "RET_ HDW_SF").ToStri ng()
frminfo1.PaintD eptSF.Text = myDV(rowIndex)( "PNT_DEPT_SF"). ToString()
frminfo1.PaintC omputer.Text = myDV(rowIndex)( "PAINT_COMPUTER ").ToString ()
frminfo1.PrattL ambertOSO.Text =
myDV(rowIndex)( "PRATT_LAMBERT_ OSO_DATE").ToSt ring()
checkarea = myDV(rowIndex)( "BEHR").ToStrin g()
If checkarea = "Y" Then
frminfo1.Checke dListBox1.SetIt emCheckState(0, CheckState.Chec ked)
Else
frminfo1.Checke dListBox1.SetIt emCheckState(0, CheckState.Unch ecked)
End If
checkarea = myDV(rowIndex)( "BEN_MOOR").ToS tring()
If checkarea = "Y" Then
frminfo1.Checke dListBox1.SetIt emCheckState(1, CheckState.Chec ked)
Else
frminfo1.Checke dListBox1.SetIt emCheckState(1, CheckState.Unch ecked)
End If
checkarea = myDV(rowIndex)( "CALIF").ToStri ng()
If checkarea = "Y" Then
frminfo1.Checke dListBox1.SetIt emCheckState(2, CheckState.Chec ked)
Else
frminfo1.Checke dListBox1.SetIt emCheckState(2, CheckState.Unch ecked)
End If
checkarea = myDV(rowIndex)( "COLONY").ToStr ing()
If checkarea = "Y" Then
frminfo1.Checke dListBox1.SetIt emCheckState(3, CheckState.Chec ked)
Else
frminfo1.Checke dListBox1.SetIt emCheckState(3, CheckState.Unch ecked)
End If
checkarea = myDV(rowIndex)( "DEVOE").ToStri ng()
If checkarea = "Y" Then
frminfo1.Checke dListBox1.SetIt emCheckState(4, CheckState.Chec ked)
Else
frminfo1.Checke dListBox1.SetIt emCheckState(4, CheckState.Unch ecked)
End If
checkarea = myDV(rowIndex)( "DUTCH_BOY").To String()
If checkarea = "Y" Then
frminfo1.Checke dListBox1.SetIt emCheckState(5, CheckState.Chec ked)
Else
frminfo1.Checke dListBox1.SetIt emCheckState(5, CheckState.Unch ecked)
End If
checkarea = myDV(rowIndex)( "FULLER_ O_BRIEN").ToStr ing()
If checkarea = "Y" Then
frminfo1.Checke dListBox1.SetIt emCheckState(6, CheckState.Chec ked)
Else
frminfo1.Checke dListBox1.SetIt emCheckState(6, CheckState.Unch ecked)
End If
checkarea = myDV(rowIndex)( "GLIDDEN").ToSt ring()
If checkarea = "Y" Then
frminfo1.Checke dListBox1.SetIt emCheckState(7, CheckState.Chec ked)
Else
frminfo1.Checke dListBox1.SetIt emCheckState(7, CheckState.Unch ecked)
End If
checkarea = myDV(rowIndex)( "LUCITE").ToStr ing()
If checkarea = "Y" Then
frminfo1.Checke dListBox1.SetIt emCheckState(8, CheckState.Chec ked)
Else
frminfo1.Checke dListBox1.SetIt emCheckState(8, CheckState.Unch ecked)
End If
checkarea = myDV(rowIndex)( "MARTIN_SENOUR" ).ToString()
If checkarea = "Y" Then
frminfo1.Checke dListBox1.SetIt emCheckState(9, CheckState.Chec ked)
Else
frminfo1.Checke dListBox1.SetIt emCheckState(9, CheckState.Unch ecked)
End If
checkarea = myDV(rowIndex)( "OLYMPIC").ToSt ring()
If checkarea = "Y" Then
frminfo1.Checke dListBox1.SetIt emCheckState(10 , CheckState.Chec ked)
Else
frminfo1.Checke dListBox1.SetIt emCheckState(10 , CheckState.Unch ecked)
End If
checkarea = myDV(rowIndex)( "OTHER_PAINT"). ToString()
If checkarea = "Y" Then
frminfo1.Checke dListBox1.SetIt emCheckState(11 , CheckState.Chec ked)
Else
frminfo1.Checke dListBox1.SetIt emCheckState(11 , CheckState.Unch ecked)
End If
checkarea = myDV(rowIndex)( "PITTS").ToStri ng()
If checkarea = "Y" Then
frminfo1.Checke dListBox1.SetIt emCheckState(12 , CheckState.Chec ked)
Else
frminfo1.Checke dListBox1.SetIt emCheckState(12 , CheckState.Unch ecked)
End If
checkarea = myDV(rowIndex)( "PORTERS").ToSt ring()
If checkarea = "Y" Then
frminfo1.Checke dListBox1.SetIt emCheckState(13 , CheckState.Chec ked)
Else
frminfo1.Checke dListBox1.SetIt emCheckState(13 , CheckState.Unch ecked)
End If
checkarea = myDV(rowIndex)( "PPG").ToString ()
If checkarea = "Y" Then
frminfo1.Checke dListBox1.SetIt emCheckState(14 , CheckState.Chec ked)
Else
frminfo1.Checke dListBox1.SetIt emCheckState(14 , CheckState.Unch ecked)
End If
checkarea = myDV(rowIndex)( "PRATT").ToStri ng()
If checkarea = "Y" Then
frminfo1.Checke dListBox1.SetIt emCheckState(15 , CheckState.Chec ked)
Else
frminfo1.Checke dListBox1.SetIt emCheckState(15 , CheckState.Unch ecked)
End If
checkarea = myDV(rowIndex)( "RALPH_LAUREN") .ToString()
If checkarea = "Y" Then
frminfo1.Checke dListBox1.SetIt emCheckState(16 , CheckState.Chec ked)
Else
frminfo1.Checke dListBox1.SetIt emCheckState(16 , CheckState.Unch ecked)
End If
checkarea = myDV(rowIndex)( "VALSPAR").ToSt ring()
If checkarea = "Y" Then
frminfo1.Checke dListBox1.SetIt emCheckState(17 , CheckState.Chec ked)
Else
frminfo1.Checke dListBox1.SetIt emCheckState(17 , CheckState.Unch ecked)
End If
checkarea = myDV(rowIndex)( "VAN_SICKLE").T oString()
If checkarea = "Y" Then
frminfo1.Checke dListBox1.SetIt emCheckState(18 , CheckState.Chec ked)
Else
frminfo1.Checke dListBox1.SetIt emCheckState(18 , CheckState.Unch ecked)
End If
frminfo.myDVR = myDV(rowIndex) 'or myDV.Item(rowIn dex)
frminfo.Show()
End Sub
I know there is a lot of code here; hopefully someone understands what I'm
doing and I'm not wasting lots of efforts on something that could be done
easily.
From the most novice VB.NET 2003 (maybe 5 weeks self taught).
THanks,
Steve
"Cor Ligthert [MVP]" <no************ @planet.nl> wrote in message
news:uc******** ******@TK2MSFTN GP05.phx.gbl...
Stephen,
You have given a lot of information and still it is not easy to help you.
Therefore some explanations.
A datarowview is a view on a datarow not to real datarow. You can get it
by
Datarowview.row
If you do an update than you can do using the DataAdapter a datarow, there
is nothing wrong with.
If you need more information, because we are here very basic.
- did you generate the dataadapter (and with that the update commands)
- what controls did you use
- did you use databinding
I hope this helps sofar,
Cor
"Stephen Plotnick" <sp*******@grou pcbf.com> schreef in bericht
news:n5******** *************** *******@giganew s.com... 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
ItemInformation 1 Form
ItemInformation 2 Form
.
.
ItemInformation 7 Form
I am able to get from the DataViewRow
I am able to put data back into the DataViewRow
As I go Forward and Backwards between the ItemInformation Form[1-7] all
the data I change is available and working
I feel pretty good about my first attempt to VB.NET
Now what I want to do:
Setup a button on all ItemInformation[1-7] Forms to do an update
In the public class setup a variable that I can change when clicking on
the Update button to denote an update is needed
From within MainSelectForm do the update from the DataViewRow in the
public class
My questions are:
1. How do I check the Update Flag? (I've migrated from COBOL where I
would be able to check the update flag in a linkage section, I do not
know how to do this in OO because I do not have control)
2. IS the a way to do an SQL Update via the DataViewRow without having to
do the Update listing all the fields and the WHERE clause, I have over
100 fields?
3. I should be able to click an Update button from within any Form and
close Form after Form until getting back to MainSelectForm where the
Update would occur
Any assistance would be greatly apprecited,
Thanks,