| | |
Help with datagrid
Please support our VB.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Jun 2007
Posts: 24
Reputation:
Solved Threads: 0
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?
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?
•
•
Join Date: Oct 2009
Posts: 1
Reputation:
Solved Threads: 0
0
#2 Oct 11th, 2009
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
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
•
•
Join Date: Sep 2009
Posts: 292
Reputation:
Solved Threads: 38
0
#3 Oct 11th, 2009
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.
•
•
•
•
' 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.
![]() |
Similar Threads
- binding a datagrid to a datareader (ASP.NET)
- Printing the datagrid control (ASP.NET)
- How to sort the rows in the datagrid and update it successfully? (VB.NET)
- Use of DataGrid (ASP.NET)
- Remove link frame around picture in Datagrid (ASP.NET)
- Linking to E-mail through datagrid (ASP.NET)
Other Threads in the VB.NET Forum
- Previous Thread: Decompiler Help
- Next Thread: VB Mail Order Assignment
| Thread Tools | Search this Thread |
"crystal .net 2005 2008 access add advanced application array asp.net basic beginner bing c# cache code combo conficker connection connectionstring control crystalreport cuesent data database datagrid datagridview dbconnection display dropdownlist excel expose files filter firewall folder ftp google government htaccess images internet ip limit login lookup mal malware map memory mobile module ms mysql net networking open oracle picturebox port position printing printpreview problem project record relationaldatabases reports" reuse save savedialog search security service settings shutdown site soap socket sql sqldatbase sqlserver sqlserver2005 table tcp textbox users vb vb.net view virus visual visualbasic visualbasic.net visualstudio visualstudio.net web website windows wizard






