Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / Database Access / August 2005



Tip: Looking for answers? Try searching our database.

DataGrid - how detect a change in any field in 1 row, and then update table? VB6, SQL 2000

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
L Mehl - 06 Aug 2005 01:52 GMT
Hello --

A datagrid, dgrCaseSiteInput, could contain as few rows as 1.  Several of
the columns are for entry.

A cmd button successfully executes a stored procedure to update the database
based on those entries.

Problem:
I don't know how to update the table after the user changes a value in an
entry column.

I don't want to have to depend on the user clicking another record in
dgrCaseSiteInput to update the source table.
This goal is an attempt to simplify the user interface, and to allow for the
possibility that dgrCaseSiteInput might contain only 1 row.

Can someone tell me
- which Event(s) to use to trap a change, and
- what method to use to write the change to the database ...
       rsCaseSiteFetch.UpdateBatch adAffectAll  ?

I populate dgrCaseSiteInput using code at the bottom.

Thank you for any help.

Larry Mehl

---------------------------------------------------
Dim conn As New ADODB.Connection
Dim rsCaseSiteFetch As New ADODB.Recordset
Dim strSQLCaseSiteFetch As String
Dim strCaseID As String

Set conn = New ADODB.Connection
Set rsCaseSiteFetch = New ADODB.Recordset

conn.CursorLocation = adUseClient

conn.Open "PROVIDER=MSDASQL;dsn=Provisioning;uid=;pwd=;"

strCaseID = frmMain.txtCaseID.Text

strSQLCaseSiteFetch = _
     "SELECT CaseID_s, SiteID_s, HeadEndCount_s, STXInstalledYN_s, " & _
         "SiteIDParentSvr_s, SiteIDParentSTX_s, HubCount_s, " & _
         "HHPassedPerNode_s, " & _
         "SubsDigCount_s , Nodes_Site_s, " & _
         "SubsDigCountMfr_s, " & _
         "PSUAgg_Svr_s, PSUAgg_STX_s " & _
     "FROM CaseSite " & _
     "WHERE CaseID_s = '" & strCaseID & "'"

rsCaseSiteFetch.Open _
   strSQLCaseSiteFetch, _
   conn, adOpenStatic, adLockOptimistic

Set dgrCaseSiteInput.DataSource = rsCaseSiteFetch
Mark J. McGinty - 12 Aug 2005 02:09 GMT
> Hello --
>
[quoted text clipped - 8 lines]
> I don't know how to update the table after the user changes a value in an
> entry column.

To cause the data source to be updated, set the grid's bookmark property to
itself.  (That makes it think the position moved, without actually changing
it, and thus it performs record-field exchange.)

As for the best event, that will depend on your needs and preferences.  I
wrote a little tool for examining the grid's events, you can find it on
CodeGuru at the link below.

Note that you'll want to find out which events setting the bookmark, to make
sure you don't cause an event storm.

http://www.codeguru.com/vb/gen/vb_database/datagrid/article.php/c7585/

-Mark

> I don't want to have to depend on the user clicking another record in
> dgrCaseSiteInput to update the source table.
[quoted text clipped - 43 lines]
>
> Set dgrCaseSiteInput.DataSource = rsCaseSiteFetch
L Mehl - 29 Aug 2005 02:09 GMT
Mark --

Thanks for the information and for the tool.

Larry

> > Hello --
> >
[quoted text clipped - 71 lines]
> >
> > Set dgrCaseSiteInput.DataSource = rsCaseSiteFetch
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.