472,354 Members | 2,245 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,354 software developers and data experts.

fill datagrid from other table.

I have 1 dataset called "dataset1" that contains 2 tables called
"course" and "courseload".

in my form i have a datagrid. the datasource of this datagrid is
"dataset1" and the datamember is "courseload".

here's the fields of every table in my dataset.

"Course" table
CourseID
CourseCode
CourseDescription
Program
Year

"Courseload" table
CourseLoadID
CourseID
Grades

CourseID in course table is a primary key and CourseID in CourseLoad
table is a foreign key.

now my question is on how can i fill this datagrid w/ records from
course table based on the criteria like Program and Year.

example:
Course table
CourseID CourseCode Program Year
1 IT 1 BSIT 1
2 IT 2 BSIM 1
3 MATH 1 BSIT 2

so for example in my form i want to fill the datagrid w/ records from
course table that has Program = BSIT and Year = 1

so the datagrid now will have
CourseID Grades CourseLoadID
1
2

Note: I have already done this using MS Access but I ported my apps to
VB.NET
i use the Docmd.RunSQL command then the insert statement like this
one:

DoCmd.RunSQL "INSERT INTO CourseLoad ( CourseID) " _
& "SELECT Course.CourseID " _
& "FROM Course " _
& "WHERE Course.Program = " &
Forms![Students]![Program] & " AND Course.Year= " & Me!Year;

this is pretty simple w/ MS Access.

thanks in advance for any help.
Nov 21 '05 #1
4 4441
sorry i have some error on my sample data. it should be:

example:
Course table
CourseID CourseCode Program Year
1 IT 1 BSIT 1
2 IT 2 BSIM 1
3 MATH 1 BSIT 2

so for example in my form i want to fill the datagrid w/ records from
course table that has Program = BSIT and Year = 1

so the datagrid now will have
CourseID Grades CourseLoadID
1

note: the record in datagrid will have only 1 record based on the
criteria.

On Tue, 16 Nov 2004 09:24:32 +0800, jaYPee <hi******@yahoo.com> wrote:
I have 1 dataset called "dataset1" that contains 2 tables called
"course" and "courseload".

in my form i have a datagrid. the datasource of this datagrid is
"dataset1" and the datamember is "courseload".

here's the fields of every table in my dataset.

"Course" table
CourseID
CourseCode
CourseDescription
Program
Year

"Courseload" table
CourseLoadID
CourseID
Grades

CourseID in course table is a primary key and CourseID in CourseLoad
table is a foreign key.

now my question is on how can i fill this datagrid w/ records from
course table based on the criteria like Program and Year.

example:
Course table
CourseID CourseCode Program Year
1 IT 1 BSIT 1
2 IT 2 BSIM 1
3 MATH 1 BSIT 2

so for example in my form i want to fill the datagrid w/ records from
course table that has Program = BSIT and Year = 1

so the datagrid now will have
CourseID Grades CourseLoadID
1
2

Note: I have already done this using MS Access but I ported my apps to
VB.NET
i use the Docmd.RunSQL command then the insert statement like this
one:

DoCmd.RunSQL "INSERT INTO CourseLoad ( CourseID) " _
& "SELECT Course.CourseID " _
& "FROM Course " _
& "WHERE Course.Program = " &
Forms![Students]![Program] & " AND Course.Year= " & Me!Year;

this is pretty simple w/ MS Access.

thanks in advance for any help.


Nov 21 '05 #2
jaYpee,

You can do it by making an extra datatable using a select with a where
clause as you already showed.

"SELECT CourseID FROM Course WHERE Program = " _
@Program"

And then use the parameters something as
XXXdataadapter.Selectcommand.Parameters.Add("@Prog ram", MyProgram)

fill it and use that datatable as datasource
xxxDataadapter.fill(ds, "myextratable")
datagrid1.datasource = dataset.tables("myextratable")

Or you can do it with a dataview.

dim dvExtra as new dataview(mytable)
dvExtra.rowfilter = "Program = '" & myProgram & "'"

datagrid1.datasource = dvExtra

I prefer the first one.

Everything is typed in this message so watch typos or little errors.

I hope this helps?

Cor
"jaYPee" <hi******@yahoo.com>
sorry i have some error on my sample data. it should be:

example:
Course table
CourseID CourseCode Program Year
1 IT 1 BSIT 1
2 IT 2 BSIM 1
3 MATH 1 BSIT 2

so for example in my form i want to fill the datagrid w/ records from
course table that has Program = BSIT and Year = 1

so the datagrid now will have
CourseID Grades CourseLoadID
1

note: the record in datagrid will have only 1 record based on the
criteria.

On Tue, 16 Nov 2004 09:24:32 +0800, jaYPee <hi******@yahoo.com> wrote:
I have 1 dataset called "dataset1" that contains 2 tables called
"course" and "courseload".

in my form i have a datagrid. the datasource of this datagrid is
"dataset1" and the datamember is "courseload".

here's the fields of every table in my dataset.

"Course" table
CourseID
CourseCode
CourseDescription
Program
Year

"Courseload" table
CourseLoadID
CourseID
Grades

CourseID in course table is a primary key and CourseID in CourseLoad
table is a foreign key.

now my question is on how can i fill this datagrid w/ records from
course table based on the criteria like Program and Year.

example:
Course table
CourseID CourseCode Program Year
1 IT 1 BSIT 1
2 IT 2 BSIM 1
3 MATH 1 BSIT 2

so for example in my form i want to fill the datagrid w/ records from
course table that has Program = BSIT and Year = 1

so the datagrid now will have
CourseID Grades CourseLoadID
1
2

Note: I have already done this using MS Access but I ported my apps to
VB.NET
i use the Docmd.RunSQL command then the insert statement like this
one:

DoCmd.RunSQL "INSERT INTO CourseLoad ( CourseID) " _
& "SELECT Course.CourseID " _
& "FROM Course " _
& "WHERE Course.Program = " &
Forms![Students]![Program] & " AND Course.Year= " & Me!Year;

this is pretty simple w/ MS Access.

thanks in advance for any help.

Nov 21 '05 #3
Thank you very much for the reply. I just want to know how this code
works. since i'm not new to VB.NET and i'm not also an expert i don't
know if this code needs to pull the data from the sql server. and if
so how can i update then the datagrid since in my app the datasource
is dataset1 and the datamember is courseload.

On Tue, 16 Nov 2004 09:41:25 +0100, "Cor Ligthert"
<no************@planet.nl> wrote:
jaYpee,

You can do it by making an extra datatable using a select with a where
clause as you already showed.

"SELECT CourseID FROM Course WHERE Program = " _
@Program"

And then use the parameters something as
XXXdataadapter.Selectcommand.Parameters.Add("@Pro gram", MyProgram)

fill it and use that datatable as datasource
xxxDataadapter.fill(ds, "myextratable")
datagrid1.datasource = dataset.tables("myextratable")

Or you can do it with a dataview.

dim dvExtra as new dataview(mytable)
dvExtra.rowfilter = "Program = '" & myProgram & "'"

datagrid1.datasource = dvExtra

I prefer the first one.

Everything is typed in this message so watch typos or little errors.

I hope this helps?

Cor
"jaYPee" <hi******@yahoo.com>
sorry i have some error on my sample data. it should be:

example:
Course table
CourseID CourseCode Program Year
1 IT 1 BSIT 1
2 IT 2 BSIM 1
3 MATH 1 BSIT 2

so for example in my form i want to fill the datagrid w/ records from
course table that has Program = BSIT and Year = 1

so the datagrid now will have
CourseID Grades CourseLoadID
1

note: the record in datagrid will have only 1 record based on the
criteria.

On Tue, 16 Nov 2004 09:24:32 +0800, jaYPee <hi******@yahoo.com> wrote:
I have 1 dataset called "dataset1" that contains 2 tables called
"course" and "courseload".

in my form i have a datagrid. the datasource of this datagrid is
"dataset1" and the datamember is "courseload".

here's the fields of every table in my dataset.

"Course" table
CourseID
CourseCode
CourseDescription
Program
Year

"Courseload" table
CourseLoadID
CourseID
Grades

CourseID in course table is a primary key and CourseID in CourseLoad
table is a foreign key.

now my question is on how can i fill this datagrid w/ records from
course table based on the criteria like Program and Year.

example:
Course table
CourseID CourseCode Program Year
1 IT 1 BSIT 1
2 IT 2 BSIM 1
3 MATH 1 BSIT 2

so for example in my form i want to fill the datagrid w/ records from
course table that has Program = BSIT and Year = 1

so the datagrid now will have
CourseID Grades CourseLoadID
1
2

Note: I have already done this using MS Access but I ported my apps to
VB.NET
i use the Docmd.RunSQL command then the insert statement like this
one:

DoCmd.RunSQL "INSERT INTO CourseLoad ( CourseID) " _
& "SELECT Course.CourseID " _
& "FROM Course " _
& "WHERE Course.Program = " &
Forms![Students]![Program] & " AND Course.Year= " & Me!Year;

this is pretty simple w/ MS Access.

thanks in advance for any help.


Nov 21 '05 #4
Forget it. Your code never works if you didn't change datasource and
datamember of DataGrid.

"jaYPee" wrote:
Thank you very much for the reply. I just want to know how this code
works. since i'm not new to VB.NET and i'm not also an expert i don't
know if this code needs to pull the data from the sql server. and if
so how can i update then the datagrid since in my app the datasource
is dataset1 and the datamember is courseload.

Nov 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Mervin Williams | last post by:
I have several tables involved in my application, but the two in question here are the company and address tables. The company table has business_address_id and mailing_address_id columns, which...
6
by: JeffB | last post by:
I have tried several different methods of getting a datagrid to fill with information. Below is the code I'm now using. When viewed in the browser and the text box filled with a parameter value...
4
by: Dave Edwards | last post by:
I understand that I can fill a datagrid with multiple queries, but I cannot figure out how to fill a dataset with the same query but run against multiple SQL servers, the query , table structure...
0
by: Marcin Podle¶ny | last post by:
Hello! I use DataGrid which displays data in several columns. Number of columns depends on user prefferences (I mean: this is still the same query filling datatable but I use...
4
by: jaYPee | last post by:
I have already done some code to fill the datagrid. my problem is that the fill method is too slow after executing my code. here is the scenario. i have a parent/child form. all is datagrid....
2
by: Brett | last post by:
I have the following code in VS Studio .NET 2005 beta: Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.DataAdapter1.Fill(DataSet1) ...
10
by: Rich | last post by:
I have a stored procedure on Sql Server2k. I can fill a data table which I can append to a dataset using an ADODB recordset object which gets populated from a command object that runs the sp. I...
2
by: MDB | last post by:
Hello All, I have a data grid that I fill using a dataset. The results of the query has around 15 columns and 500 rows (and growing). The reason I am using the datagrid is so the end users can...
3
by: monika varshney | last post by:
I have a sql server table and i want to read it in the datagrid view of C# .Net. I think it is easy to do it. but i m not able to show any output in the datagrid... here is my code.please guide...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. header("Location:".$urlback); Is this the right layout the...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it so the python app could use a http request to get...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.