databind & find

  • Thread starter Thread starter Agnes
  • Start date Start date
A

Agnes

Sorry for my question again.
My form got the previous , next , top,bottom button and allow the user to
move the records . Now, the table got 500 records, I need to do a features
for the user to input the 300th records(e.g invoiceno is 00301) and search
it, and then move to 301,302, or move back to 299,298.

I don't know how to do , Thanks in advance.
 
Hi Agnes,

A sample I made yesterday, I think that it fits all your problem, instead of
buttons I use a listbox which shows it even nicer. It is a sample, there is
no valuating or things like that in it.

I hope this helps?

Cor
\\\
Private Sub FillDatasetAndBindings()
ds.Clear()
Dim sqlString As String = "Select * from countries"
da = New OleDb.OleDbDataAdapter(sqlString, conn)
da.Fill(ds)
Dim dt As DataTable = ds.Tables(0)
dv = New DataView(dt)
dv.Sort = "Id"
cma = DirectCast(BindingContext(dv), CurrencyManager)
Dim cmb As New OleDb.OleDbCommandBuilder(da)
TextBox1.DataBindings.Clear()
TextBox2.DataBindings.Clear()
TextBox1.DataBindings.Add("text", dv, "Id")
TextBox2.DataBindings.Add("text", dv, "Name")
ListBox1.DataSource = dv
ListBox1.DisplayMember = "Name"
If ds.Tables(0).Rows.Count = 0 Then
cma.AddNew()
TextBox1.Focus()
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
'Adding of a new row
cma.AddNew()
TextBox1.Focus()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button2.Click
'Delete
dv(cma.Position).Delete()
End Sub
Private Sub Button3_Click_1(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button3.Click
'Add it to the dataset and to the
cma.EndCurrentEdit()
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button4.Click
'Write it to the database
cma.EndCurrentEdit()
If ds.HasChanges Then
Try
da.Update(ds)
Catch ex As OleDb.OleDbException
MessageBox.Show(ex.Message, "OleDbException")
Exit Sub
Catch ex As Exception
MessageBox.Show(ex.Message, "GeneralException")
Exit Sub
End Try
End If
End Sub
////
 
Hey, great coding man.

Need some more help from you guy, if you don't mind.

Now I'm trying to add a second table to my dataset, this is the code I've
come up with.
Dim SqlString As String = "SELECT * FROM tb_Test2"

da = New SqlDataAdapter(SqlString, ConnectionString)

da.Fill(ds)

Dim dt As DataTable = ds.Tables(1) Is this the Right way to add another
table to the dataset??? it says that it cannot find the table 1

dv = New DataView(dt)

dv.Sort = "ID"

cmaBilling = DirectCast(BindingContext(dv), CurrencyManager)

Dim cmb As New SqlCommandBuilder(da)

and then the binding part follows.

Thanks bud for your great help.
Manuel
 
Hi Manuel,

You are almost imposible to help, you drop everywhere your messages.
I said to you that it is better to stay in the original thread, than there
can be looked back what was your problem. And to add questions to messages
like everybody else do so it is showed that it is a question.

Now for everybody else this looks as an asnwer to the qeustion from Agnes/

Your answer

da.fill(ds, "dt1") ' is what I think is the most easy one.

And you can make a choise to make two dataadapters or to do everytime a new
commandbuilder before the update).

I think that make one time two dataadapters will be the most efficient when
you are updating. (Without updating you can go for one).

I hope this helps?

Cor
 
Hey Cor, sorry about the multiposting again. I did that just in case you
missed this one.
Hey bud, I know you said that I could add a second dataadapter for the other
table. now how can I tied together so when I click an item on the list box,
both tabs would display the same ID data from the different table?

Thanks so much for your great day man.

Manuel
 
Back
Top