Please help me with my ssdbGrid problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • e4r3i5c
    New Member
    • Aug 2008
    • 6

    Please help me with my ssdbGrid problem

    Hi, i have a problem with my ssdbgrid in vb6. the task is to find and highlight selected row in the grid.. . . Is there anyone can help me with this problem?..
    my code below is to select the specfic records or row but the problem is, my code cannot highlight the row..How can i?Please help me i need it badly...


    i = 0
    ssdg1.MoveFirst
    For i = 1 To ssdg1.Rows

    If ssdg1.Columns(" Description").T ext = frmDailyActivit ies.ssdg.Column s "Activity Code").Text Then

    ssdg1.SelBookma rks.Add ssdg1.RowBookma rk(i)
    Exit For
    End If
    ssdg1.MoveNext

    Next i
  • Dököll
    Recognized Expert Top Contributor
    • Nov 2006
    • 2379

    #2
    Hey there Good buddy!

    Why not give this one a whirl:

    [CODE=VB]
    Option Explicit

    Dim cn As New ADODB.Connectio n
    Dim rs As New ADODB.Recordset
    Dim cmd As New ADODB.Command
    Dim i As Integer
    Dim FindLastName As String

    Private Sub Command1_Click( )

    ' Remove previously saved bookmark from collection
    If (DataGrid1.SelB ookmarks.Count <> 0) Then
    DataGrid1.SelBo okmarks.Remove 0
    End If

    ' Prompt user for desired author's last name
    FindLastName = InputBox("Pleas e enter the author's last name you
    want to search for", "Find")

    rs.Find "au_lname = '" & FindLastName & "'", , , 1

    ' Append your bookmark to the collection of selected rows
    DataGrid1.SelBo okmarks.Add rs.Bookmark

    End Sub

    Private Sub Form_Load()

    ' Open your ADO connection where "Pubs" is an ODBC DSN that
    ' points to pubs database in SQL Server
    cn.Open "Pubs"

    ' Create your command to query for all records in Authors table
    With cmd
    .ActiveConnecti on = cn
    .CommandText = "select * from authors"
    End With

    ' Open your recordset
    With rs
    ' Set rs properties
    .CursorType = adOpenKeyset
    .LockType = adLockOptimisti c

    ' Call open using active command
    .Open cmd
    End With

    ' Populate the DataGrid providing rs as the data source
    Set DataGrid1.DataS ource = rs

    End Sub
    [/CODE]



    See if that works!

    Comment

    • e4r3i5c
      New Member
      • Aug 2008
      • 6

      #3
      Thanks Dokoll, I've got the problem with my code..when i change the syntax of the bookmark the problem was solved.. thank you very much for helping..
      more power..

      Comment

      Working...