473,748 Members | 6,664 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

SQL Update - DataViewRow

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,
Jun 18 '06 #1
5 2598
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,

Jun 19 '06 #2
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,


Jun 19 '06 #3
Stephen,

It is really to much code to investigate in a newsgroup.

If it is so much than it is better to make a simple sample and try that
yourself first, that is easier to communicate about.

However, if I look to this code, than I get the idea that you try to enter
data using the datagrid.
That is the last thing you should do.

On our website are many samples about the use of the datagrid. Have a look
at some of those, I have selected one for you.

Be aware that if you want to use seperated textboxes or whatever, than you
can use databinding to those controls. The bindingmanager takes than care
that you select the same row in the datagrid as the information in your
textboxes.

http://www.vb-tips.com/default.aspx?...f-587f730fa118

I hope that this is a start.

Cor
"Stephen Plotnick" <sp*******@grou pcbf.com> schreef in bericht
news:ss******** *************** *******@giganew s.com...
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.Enable d = 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.Enable d = False

End With

With aCol3

.MappingName = "STORE"

.HeaderText = "Store Name"

.Width = 200

.Alignment = HorizontalAlign ment.Left

' .NullText = ""

.TextBox.Enable d = False

End With

With aCol4

.MappingName = "ADDRESS"

.HeaderText = "Store Address"

.Width = 200

.Alignment = HorizontalAlign ment.Left

'.NullText = "0"

.TextBox.Enable d = False

'.Format = "#0.00"

End With

With aCol5

.MappingName = "CITY"

.HeaderText = "CIty"

.Width = 100

.Alignment = HorizontalAlign ment.Left

'.NullText = "0"

.TextBox.Enable d = False

'.Format = "#0.00"

End With

With aCol6

.MappingName = "STATE"

.HeaderText = "St."

.Width = 30

.Alignment = HorizontalAlign ment.Left

'.NullText = "0"

.TextBox.Enable d = 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,



Jun 19 '06 #4
I think I have eerything worked out except one thing.

I can get fields out of and back into the DataViewRow variable I created in
a Public class.

When I need to do an SQL UPDATE can I use the DataViewRow directly or do I
need to do an SQL UPDATE using fld1, fld2, fld3, ....fld100 USING ITEMNO.

Steve
"Cor Ligthert [MVP]" <no************ @planet.nl> wrote in message
news:Oa******** ******@TK2MSFTN GP03.phx.gbl...
Stephen,

It is really to much code to investigate in a newsgroup.

If it is so much than it is better to make a simple sample and try that
yourself first, that is easier to communicate about.

However, if I look to this code, than I get the idea that you try to enter
data using the datagrid.
That is the last thing you should do.

On our website are many samples about the use of the datagrid. Have a look
at some of those, I have selected one for you.

Be aware that if you want to use seperated textboxes or whatever, than you
can use databinding to those controls. The bindingmanager takes than care
that you select the same row in the datagrid as the information in your
textboxes.

http://www.vb-tips.com/default.aspx?...f-587f730fa118

I hope that this is a start.

Cor
"Stephen Plotnick" <sp*******@grou pcbf.com> schreef in bericht
news:ss******** *************** *******@giganew s.com...
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.Enable d = 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.Enable d = False

End With

With aCol3

.MappingName = "STORE"

.HeaderText = "Store Name"

.Width = 200

.Alignment = HorizontalAlign ment.Left

' .NullText = ""

.TextBox.Enable d = False

End With

With aCol4

.MappingName = "ADDRESS"

.HeaderText = "Store Address"

.Width = 200

.Alignment = HorizontalAlign ment.Left

'.NullText = "0"

.TextBox.Enable d = False

'.Format = "#0.00"

End With

With aCol5

.MappingName = "CITY"

.HeaderText = "CIty"

.Width = 100

.Alignment = HorizontalAlign ment.Left

'.NullText = "0"

.TextBox.Enable d = False

'.Format = "#0.00"

End With

With aCol6

.MappingName = "STATE"

.HeaderText = "St."

.Width = 30

.Alignment = HorizontalAlign ment.Left

'.NullText = "0"

.TextBox.Enable d = 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,



Jun 20 '06 #5
Steve,

You use in my idea your own method completely different from others. I am
afraid that you will see yourself in future, by instance that help in those
methods is impossible to give.

Sorry,

Cor

"Stephen Plotnick" <sp*******@grou pcbf.com> schreef in bericht
news:2J******** *************** *******@giganew s.com...
I think I have eerything worked out except one thing.

I can get fields out of and back into the DataViewRow variable I created
in a Public class.

When I need to do an SQL UPDATE can I use the DataViewRow directly or do I
need to do an SQL UPDATE using fld1, fld2, fld3, ....fld100 USING ITEMNO.

Steve
"Cor Ligthert [MVP]" <no************ @planet.nl> wrote in message
news:Oa******** ******@TK2MSFTN GP03.phx.gbl...
Stephen,

It is really to much code to investigate in a newsgroup.

If it is so much than it is better to make a simple sample and try that
yourself first, that is easier to communicate about.

However, if I look to this code, than I get the idea that you try to
enter data using the datagrid.
That is the last thing you should do.

On our website are many samples about the use of the datagrid. Have a
look at some of those, I have selected one for you.

Be aware that if you want to use seperated textboxes or whatever, than
you can use databinding to those controls. The bindingmanager takes than
care that you select the same row in the datagrid as the information in
your textboxes.

http://www.vb-tips.com/default.aspx?...f-587f730fa118

I hope that this is a start.

Cor
"Stephen Plotnick" <sp*******@grou pcbf.com> schreef in bericht
news:ss******** *************** *******@giganew s.com...
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.Enable d = 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.Enable d = False

End With

With aCol3

.MappingName = "STORE"

.HeaderText = "Store Name"

.Width = 200

.Alignment = HorizontalAlign ment.Left

' .NullText = ""

.TextBox.Enable d = False

End With

With aCol4

.MappingName = "ADDRESS"

.HeaderText = "Store Address"

.Width = 200

.Alignment = HorizontalAlign ment.Left

'.NullText = "0"

.TextBox.Enable d = False

'.Format = "#0.00"

End With

With aCol5

.MappingName = "CITY"

.HeaderText = "CIty"

.Width = 100

.Alignment = HorizontalAlign ment.Left

'.NullText = "0"

.TextBox.Enable d = False

'.Format = "#0.00"

End With

With aCol6

.MappingName = "STATE"

.HeaderText = "St."

.Width = 30

.Alignment = HorizontalAlign ment.Left

'.NullText = "0"

.TextBox.Enable d = 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,
>



Jun 21 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
248475
by: Dave | last post by:
I have 2 tables, one with names, and another with addresses, joined by their CIVICID number (unique to the ADDRESSINFO table) in Oracle. I need to update a field in the NAMEINFO table for a particular surname in a particular town. I can select the records fine with this syntax (testing in Oracle SQL* Plus) SELECT NAMEINFO.LASTNAME, NAMEINFO.FIRSTNAME, NAMEINFO.MIDDLENAME, NAMEINFO.GENDER, ADDRESSINFO.REGION FROM NAMEINFO, ADDRESSINFO...
8
89312
by: Lauren Quantrell | last post by:
In VBA, I constructed the following to update all records in tblmyTable with each records in tblmyTableTEMP having the same UniqueID: UPDATE tblMyTable RIGHT JOIN tblMyTableTEMP ON tblMyTable.UniqueID = tblMyTableTEMP.UniqueID SET tblMyTable.myField = tblMyTableTEMP.myField, tblMyTable.myField2 = tblMyTableTEMP.myField2,
27
2539
by: VK | last post by:
<http://www.jibbering.com/faq/#FAQ3_2> The parts where update, replacement or add-on is needed are in <update> tag. 3.2 What online resources are available? Javascript FAQ sites, please check these first:- <http://developer.irt.org/script/script.htm>
16
17017
by: Philip Boonzaaier | last post by:
I want to be able to generate SQL statements that will go through a list of data, effectively row by row, enquire on the database if this exists in the selected table- If it exists, then the colums must be UPDATED, if not, they must be INSERTED. Logically then, I would like to SELECT * FROM <TABLE> WHERE ....<Values entered here>, and then IF FOUND UPDATE <TABLE> SET .... <Values entered here> ELSE INSERT INTO <TABLE> VALUES <Values...
1
3573
by: Bill | last post by:
This test is generating a compile error: private void BuildFTPRec(DataRowView a, DataRowView h) { foreach (DataRow r in a) { foreach (DataColumn dc in r) { Console.WriteLine(r.ToString()); }
2
1624
by: Johann Blake | last post by:
When adding a new row to a DataView, is it possible to cast the returned DataViewRow to a typed row? Without casting, I am forced to indicate the names of fields as strings when setting their values. Example: DataRowView drv = myDataset.SomeTable.DefaultView.AddNew(); drv = Guid.NewGuid(); drv.EndEdit(); Since I already have a typed Dataset, it would be nice if there was a
1
4014
by: John Chorlton | last post by:
I've been attempting to pass a chunk of data back from a child Windows form using public properties on the form and have been getting some odd errors. I wanted to return a row of data to avoid creating many public properties on the form to do the same thing. At first I tried returning a DataViewRow. This worked fine until I reached the phone field on the parent table and the code Child form public DataRowView SelectedAddres ge ...
3
3451
by: Shapper | last post by:
Hello, I have created 3 functions to insert, update and delete an Access database record. The Insert and the Delete code are working fine. The update is not. I checked and my database has all the necessary records in it when testing it. I get the error "No value given for one or more required parameters." when I try to update the database. Can you tell me what am I doing wrong?
9
12987
by: jaYPee | last post by:
I have search a lot of thread in google newsgroup and read a lot of articles but still i don't know how to update the dataset that has 3 tables. my 3 tables looks like the 3 tables from northwind database that has an employees, orders, and order details. the following are the 3 tables in my sql database students schyrsem
0
8987
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9534
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9366
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9241
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8239
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6073
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4867
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3303
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2211
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.