944,082 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 2548
  • VB.NET RSS
Sep 13th, 2009
0

Help with datagrid

Expand Post »
Hi everyone!

I am having difficulties in terms of manipulating data using datagrid. So my problem is this, I have 2 forms;namely, a form for logging in, then secondly, a form which is similar to an inbox. I have a datagrid in my inbox to call on records in my database. The datagrid shows all records, but what I want is to limit data per login of the user. So for example, if I login as "Username" the datagrid will show all the transactions done only by this specific "Username".

What I've tried:
1.) I've tried to pass one variable from my Login Form to my Homepage form then set a place to which I can call the data, namely the Username, afterwhich I've added to it to my sql statement and tried to call on the data, but it doesn't seem to work.

Can anyone give me an idea?
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Alphard is offline Offline
24 posts
since Jun 2007
Oct 11th, 2009
0
Re: Help with datagrid
Hi alphard;
in my opinion what you should do id have two tables in your database one is "username" second is transaction.
Get the relation done between the 2 tables so that username is the primary key flield which is related to username in transaction table,many to one relationship.
Now starting from vb.net editor code, you should add a tool
oledbconnection and 2 dataadapters because you have 2 tables. The wizard will open for the sql statement one for each dataadapter, set the tables by selecting then, through sqlqueries.
Then generate a dataset that englobes the 2 tables.
After that click twice on the .xsd file and sort the schema by
adding a new relation ship ((username via transaction id)).
Use the fill method to fill the data set.
Write the necessary statements to save back to the database:

Like getchanges and update dataadapter and accept changes.

Youare set up.

Make a button to trigger the code like name it get data.
You will see that in the datagrid shows the username and besides it there is a plus sign, click it and you would have the transactions for that username.

Good luck
Reputation Points: 10
Solved Threads: 0
Newbie Poster
eliot is offline Offline
5 posts
since Oct 2009
Oct 11th, 2009
0
Re: Help with datagrid
I would have to disagree with the majority of the above reply. You should not be retrieving un-needed data from a database and holding it in memory. Write your query to get only the records that you need for this single user.

Click to Expand / Collapse  Quote originally posted by eliot ...

' You do not need to retrieve and store all users in your db.
' Likewise you don't need to retrieve all mail records.
' You have the login username, you only need a
' single table to query the records belonging to this user.

in my opinion what you should do id have two tables in your database one is "username" second is transaction.

Get the relation done between the 2 tables so that username is the primary key flield which is related to username in transaction table,many to one relationship.

' Again this is un-needed but just wanted to point out that
' you do not need seperate DataAdapters for every DataTable in
' a DataSet.
' Also I would suggest writing all your queries as stored procedures
' in whatever database you are using. It is more efficient, flexible
' and provides reusability for other datasets having the
' same queries within your app or other apps using the same db.

Now starting from vb.net editor code, you should add a tool
oledbconnection and 2 dataadapters because you have 2 tables. The wizard will open for the sql statement one for each dataadapter, set the tables by selecting then, through sqlqueries.
Then generate a dataset that englobes the 2 tables.

After that click twice on the .xsd file and sort the schema by
adding a new relation ship ((username via transaction id)).
Use the fill method to fill the data set.

Write the necessary statements to save back to the database:

' Explicitly calling a Dataset/DataTable's AcceptChanges method
' seems to be a very common mistake by many programmers.
' In truth this is rarely needed. Your DataAdapter will automatically
' adjust the row state changes after any action command has
' been executed.


Like getchanges and update dataadapter and accept changes.

Youare set up.

Make a button to trigger the code like name it get data.

' You can not show multiple tables in a single
' DataGridView control in .Net.


You will see that in the datagrid shows the username and besides it there is a plus sign, click it and you would have the transactions for that username.
Last edited by TomW; Oct 11th, 2009 at 6:45 pm.
Reputation Points: 84
Solved Threads: 48
Posting Whiz
TomW is offline Offline
342 posts
since Sep 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: Decompiler Help
Next Thread in VB.NET Forum Timeline: VB Mail Order Assignment





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC