Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hello,

 

i've got a little Problem. I would like to get some Information from a MySQL Database and store these information in a class/function so i have quick access. The information i would like to store are customer information and i would like to get information by using "customers("nameofcustomer").phone" (to get the phone number) or "customers("name").delete" for deleting a customer.

Is this possible to do? I don't want to store thousands of customers but using mysql is too slow.

Any other Solution would be great too :).

 

Thanks in advance,

Twister

Posted

mySQL databases are pretty fast. Are you connecting over the internet and grabbing individual records or something?

 

Anywho... There isn't much to it once you have a connection. Create a class with properties (the database fields you want), query the record you want and put the information in the class variable.

 

If you want a bunch of names, make a collection/array of that variable.

 

Honestly the easiest thing to do would be to query information from the database and put it in a datatable/dataset if you're getting more than one record.

Posted

Mhmm... I thought it would save some time if i could get the information w/o connecting to mysql.

another thing i'm doing is something like a ranking list:

2 - Max

4 - Peter

5 - Susann

1 - Thorsten

 

And then i would like to sort this, but at the same time i would like to store informations to each of the persons. And I thought some sort of a class would be helpful in this case.

 

Thanks in advances,

Twister

Posted
Mhmm... I thought it would save some time if i could get the information w/o connecting to mysql.

another thing i'm doing is something like a ranking list:

2 - Max

4 - Peter

5 - Susann

1 - Thorsten

 

And then i would like to sort this, but at the same time i would like to store informations to each of the persons. And I thought some sort of a class would be helpful in this case.

 

Thanks in advances,

Twister

 

If the information is in a mySQL database, you need to connect to it. There isn't a way around that.

 

You just do a simple query: "SELECT * FROM <table> ORDER by <Ranking Field>" and you'll be returned a datatable with all the records on said table in order from 1 to 5 (or whatever).

 

Many things you can do to change the query. In general, thats one of the benefits of using a database is that you can do a lot of data manipulation (reordering, filtering, figured fields) on the query and just worry about the data you're given. True, .Net has classes that help you filter and sort datatables (and bindingsources in 2005).

 

If the data is in a mySQL database: Connect, use your querry to grab data into a datatable and use the data. Thats the easiest way.

 

You can create a custom class to act like a datatable or datarow (a record) if you want. Thats up to you. I think the .net dataset/datatable/datarows are good for the job, though I'm often not terribly hot about using a datarow on a typed datatable... I always end up fumbling it for a while before getting it right.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...