Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Simple Databse Question.

Posted on 2004-10-19
11
Medium Priority
?
138 Views
Last Modified: 2010-04-23
Hi, I dont want to bind my data to anything, except maybe an array which im not sure how to do, my question here is, that I would like to know the proper way in dealing wtih databases, as of right now I have two tables, I will constantly need to be searching thru each one of them for things in different fields, and I will constantly be adding to one of the tables, at a very fast rate for the most part. My question is how would I go about doing this correctly?
Would I open one connection for the db?
What would be the fastest way to search for something in say table: tblnick field: lastseen searching for: "Two" and return that row id?
Will I be updating after every entry? or is that only when i save? I will need uptodate results.
thank you =)

0
Comment
Question by:addicktz
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
11 Comments
 
LVL 7

Expert Comment

by:J_Mak
ID: 12353451
This link will have everything you need to know about what you need to do:

http://samples.gotdotnet.com/quickstart/howto/doc/adoplus/adoplusoverview.aspx

If you look on the left pane you'll have topics like " Update a Database from a DataSet" which is one of your queries. Plus there are plenty more useful links. Hope that helps.
0
 
LVL 1

Author Comment

by:addicktz
ID: 12353599
I appreciate the link but wasnt what I was looking for, But here's something else to add to this question,
would it be possible to bind a table to a structure?

public structure bot
dim address as string
dim nick as string
end structure

dim bots() as bot
redim bots(db.rows.count) as bot

and then bind the two fields in the database to bots().address and bots().nick with maybe a loop?


0
 
LVL 1

Author Comment

by:addicktz
ID: 12353607
and have new instances of bots() be recorded to the db ?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 9

Expert Comment

by:checoo
ID: 12354932
i am not sure whether you can bind to a structure, but definitely you can bind to a class, by just inheriting it from control. Take a look at the followin example --

PUblic class bot
inherits control
dim address as string
dim nick as string
end class

dim bots() as bot
redim bots(db.rows.count) as bot

bots(0).databindings.add("address",dataset,"tablename")
0
 
LVL 19

Expert Comment

by:arif_eqbal
ID: 12354944
Well in your case i think the best way is to have a Dataset with two tables.
The dataset will be disconnected so yuo need just one connection say on Form Load and fill the Tables in the DataBase.

As for the tables where you'll have heavy DataEntry, You can have the Entries in disconnected mode (Unless of course where you have an AutoGenerate Primary Key and more than one Users, in such a case you'll need some concurrency measures)
After all the entries are done database connection can be opened and all data stored back.

Now for the table from where you need to search often, You can use DataViews to filter the records in the second table giving where clause like "lastseen = 'Two'"

0
 
LVL 4

Expert Comment

by:eozz_2000
ID: 12355143
I prefer to use dataView objects, in different comboBox objects you can select the search criteria from them and then update the rowFilter property of your dataView, when I want to filter very fast, i do this.
0
 
LVL 4

Expert Comment

by:eozz_2000
ID: 12355149
Well, I fill the comboBox objects manually, because if I do this in that way, I can add an 'All' item to indicate that that criteria will be discarded.
0
 
LVL 1

Author Comment

by:addicktz
ID: 12358814
eozz: can you say all that again in a tad more detail, and maybe show some sample code?

you guys have been very helpful, thank you all.
0
 
LVL 4

Expert Comment

by:eozz_2000
ID: 12364502
Ups, well, the code could be so large... but with this explanation I think you'll understand:

-Suppose that you have this table Products(Name, Size, Cost, Color)
-You must create 4 comboBox

The code of the first comboBox is this:

dim com as new OleDbCommand("SELECT DISTINCT Name FROM Products",Connection)
dim dr as OleDbDataReader = com.ExecuteReader()
while dr.Read
    me.cbName.Items.Add(dr.Item("Name"))
wend
me.cbName.Items.Add "All"

You must analog things to fill the other comboBox

-In the selectedIndexChanged of your comboBox objects you must do something like this:

me.ApplyFilters()

private sub ApplyFilters()
    dim bolFirst as Boolean = True
    myDataView.rowFilter = ""
    if cbName.Text <> "All" then
        bolFirst = False
        myDataView.RowFilter = "Name = '" & cbName.Text & "'"
    end if
    if cbSize.Text <> "All" then
        if not bolFirst then myDataView.RowFilter &= ", "
        myDataView.RowFilter &= "Size = '" & cbSize.Text & "'"
    end if
    if cbCost.Text <> "All" then
        if not bolFirst then myDataView.RowFilter &= ", "
        myDataView.RowFilter &= "Cost = '" & cbCost.Text & "'"
    end if
    if cbColor.Text <> "All" then
        if not bolFirst then myDataView.RowFilter &= ", "
        myDataView.RowFilter &= "Color = '" & cbColor.Text & "'"
    end if
end sub
0
 
LVL 1

Author Comment

by:addicktz
ID: 12366678
I am actually trying to avoid putting any information in objects like listbox/combobox, I would prefer to do it in all arrays, but, my question now is, is arrays amounting to over 15000 to much?
0
 
LVL 4

Accepted Solution

by:
eozz_2000 earned 1500 total points
ID: 12372248
You are going to work with a lot of memory, I would prefer to work with data that I will need in the moment.
I didn't unerstand... you asked a way to filter your table... I have put code that to that... what else you want?
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question