Working with BindingNavigator

Knvn

Well-known member
Joined
Dec 30, 2009
Messages
45
Programming Experience
Beginner
Hi,

The code I witten below will selects the reords from 2 different tables(Usually 3 records will be selected).
Where, bs is a BindingSource.
According to the records, BindingNavigatorCountItem must contain 3.
But when I run the program the count is only 1 and all position buttons are disabled.


VB.NET:
    Try
            stdrs.Open("Select * from " & dpt & " where Sno='" & strno & "'", _
                       cnn,CursorTypeEnum.adOpenDynamic,LockTypeEnum.adLockOptimistic)
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try

        bs.DataSource = stdrs
        BindingNavigator1.BindingSource = bs

Please help me....
 
I'm only seeing 1 table here from your query. Try typing the query directly into SQL Server and see what results you get.
 
Quite a few things wrong with that code; I'd recommend you follow the official Microsoft tutorials for how to do data access. You can find links to them in the DW2 link in my signature
 
I'm only seeing 1 table here from your query. Try typing the query directly into SQL Server and see what results you get.

Oh! I’m very very sorry :eek:; accidentally I copied the wrong code. Actually the query is:

VB.NET:
Try
            stdrs.Open("Select * from " & dpt & " d," & stSem & " s Where d.Sno=s.st_no order by d.Sno", _
                       cnn, CursorTypeEnum.adOpenDynamic = CursorTypeEnum.adOpenDynamic, LockTypeEnum.adLockOptimistic)
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try

        bs.DataSource = stdrs
        BindingNavigator1.BindingSource = bs
 
Yeah. Um.. That's not helping. In fact, it's getting worse. We stopped doing data access code like that back in the 90s.

Read the DW2 link in my signature. I know you probably think reading tutorials is boring and a waste of time because you've been using databases for years and you know just how it's done, but trust me; things have moved on from what you posted. The 30 mins it will take to do the Creating a Simple Data App tutorial will be paid back by the end of your first project (it takes me about 1.5 minutes to create an app that will connect to, read, navigate in a grid and write a database table..) and your code will be much better .
 
Hi,

I’m a final year diploma student (in India).

I first want to say thanks for both cjard and MattP for giving me a good suggestion.

When I start my project in vb.net I tried to use SQL2005. But I failed to connect it from the vb.net. So I used MS Access and connect it through ADO and wrote the queries that I known. Now my project is almost (70%) completed. So I want to continue my project in this only.

I’m surely study and use the new features of this language in future. Yet I didn’t have knowledge’s about any language (even human language also).

Thank you for encouraging me,
-Naveen
 

Attachments

  • Navigator.bmp
    82.6 KB · Views: 25
To overcome from the Navigator problem I created my own Navigator and used it.
 

Attachments

  • Navigator.bmp
    82.6 KB · Views: 27
Back
Top