•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the VB.NET section within the Software Development category of DaniWeb, a massive community of 425,895 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 1,931 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our VB.NET advertiser: Programming Forums
Views: 1170 | Replies: 5 | Solved
![]() |
•
•
Join Date: Mar 2008
Posts: 9
Reputation:
Rep Power: 0
Solved Threads: 0
Hi,
I’m writing a programme in VB.NET 2008 which uses an access database; I am trying to create a query which uses the value from a textbox say txtStudentNo, to query a DataGridView say grdInfo to only show the student with the entered student number.
The problem I am having is that I can make a query and make it run correctly if the student number is applied in the actual query using the QueryBuilder, however I can not work out how to make said query look at a textbox. Everything I have found so far has been for VB.net 05 and 03, these have all said I need to use something like =@StudentNo but this will not work, Hopefully I’m just missing something simple. Thanks for your time.
I’m writing a programme in VB.NET 2008 which uses an access database; I am trying to create a query which uses the value from a textbox say txtStudentNo, to query a DataGridView say grdInfo to only show the student with the entered student number.
The problem I am having is that I can make a query and make it run correctly if the student number is applied in the actual query using the QueryBuilder, however I can not work out how to make said query look at a textbox. Everything I have found so far has been for VB.net 05 and 03, these have all said I need to use something like =@StudentNo but this will not work, Hopefully I’m just missing something simple. Thanks for your time.
Say you've button, when user presses on it fills the grid with the data filtered with your critria, OK?
So, on you button click event handler write this code
N.P: My critria was integer value
sorry but I don't know VB.NET code
So, on you button click event handler write this code
c# Syntax (Toggle Plain Text)
this.table1TableAdapter.FillBy(this.myDataSet.myTable, new System.Nullable<int>(((int)(System.Convert.ChangeType(textbox1.Text, typeof(int))))));
N.P: My critria was integer value
sorry but I don't know VB.NET code
B.Sc Computer Science, Helwan University
Microsoft Student Partner
Personal blog http://ramymahrous.blogspot.com/
Arabic technical blog http://fci-h-ar.blogspot.com/
English technical blog http://fci-h.blogspot.com/
Microsoft Student Partner
Personal blog http://ramymahrous.blogspot.com/
Arabic technical blog http://fci-h-ar.blogspot.com/
English technical blog http://fci-h.blogspot.com/
•
•
Join Date: May 2007
Posts: 36
Reputation:
Rep Power: 2
Solved Threads: 1
Right, you should use the =@studentno for your query, so it will be something like
Where StudentNo is the name of the student number column in your access database , then when you need to call the query it will be
Where StudName is the name of your query. Im still pretty new to VB too, but I just did something similar.
SELECT StudentName FROM StudentTable WHERE StudentNo = @StudentNo
Where StudentNo is the name of the student number column in your access database , then when you need to call the query it will be
StudentName.Text = StudTableAdapter.StudName(txtStudentNo.text)
Where StudName is the name of your query. Im still pretty new to VB too, but I just did something similar.
•
•
Join Date: Mar 2008
Posts: 9
Reputation:
Rep Power: 0
Solved Threads: 0
RIGHT, incase anyone ever finds this thread again, microsoft had hidden the bit i was looking for in the depths of hell.
Step one
go to the DataSetDesigner
right click your DataTable
fill stuff out as you would making a normal query using a @xxxxxx as a variable where the x's are the name of the column your want to query (Where StudentNo =@StudentNo) was my line
finish the query ignore the warning about errors on '@'
click on "fillBy,GetDataByxxxxxxx" then go to the proporties pane and under parameters
add a parameter for each of the variables you added in the query
<to filter a DataGridView>
then in your forms code
grdEpLst.DataSource = DataTable1TableAdapter1.GetDataByStudent(txtSearchFilter.text)
Step one
go to the DataSetDesigner
right click your DataTable
fill stuff out as you would making a normal query using a @xxxxxx as a variable where the x's are the name of the column your want to query (Where StudentNo =@StudentNo) was my line
finish the query ignore the warning about errors on '@'
click on "fillBy,GetDataByxxxxxxx" then go to the proporties pane and under parameters
add a parameter for each of the variables you added in the query
<to filter a DataGridView>
then in your forms code
grdEpLst.DataSource = DataTable1TableAdapter1.GetDataByStudent(txtSearchFilter.text)
![]() |
•
•
•
•
•
•
•
•
DaniWeb VB.NET Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- Previous Thread: Finding the Definiton of an MS Access database connection in VB.Net 2008
- Next Thread: Cant readline in text file.... URGENT help~


Linear Mode