473,289 Members | 1,875 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

getting the data from more than one table

hi,

i have three tables named types,books,artcles

types consist of books,artcles

books consist of title,authorname,userid(means book title and author of the book)
articles consist of title,authorname,userid(means articletitle and author of the article)


i have a datagrid ...names of the columns are in the datagrid is

type,userid,title,author


if he enters the data in the book.the type should be book and the book title should come in the title column along with userid and author name in the respective columns.

and same for article also.

how can i write the query for" if it is book,then in the title column book title has to come" in the datagrid
how can i write the query for" if it is article,in the title column article title has to come" in the datagrid

and howe can i bind this to datagrid
Aug 23 '07 #1
1 1229
dip_developer
648 Expert 512MB
hi,

i have three tables named types,books,artcles

types consist of books,artcles

books consist of title,authorname,userid(means book title and author of the book)
articles consist of title,authorname,userid(means articletitle and author of the article)


i have a datagrid ...names of the columns are in the datagrid is

type,userid,title,author


if he enters the data in the book.the type should be book and the book title should come in the title column along with userid and author name in the respective columns.

and same for article also.

how can i write the query for" if it is book,then in the title column book title has to come" in the datagrid
how can i write the query for" if it is article,in the title column article title has to come" in the datagrid

and howe can i bind this to datagrid
I dont think you are very much clear about your requirement......
Tell me who will chhose the type??
From where the type will be chosen???

I suggest you the following......
Take a combobox to choose type.....On SelectedIndexChanged event of the combobox set your sql query like this....

Expand|Select|Wrap|Line Numbers
  1.  Dim cType as String 
  2. Dim strSql as String
  3. Select Case cType 
  4. Case "Book"
  5. strSql ="SELECT  title,authorname,userid FROM book"
  6. Case "Article"
  7. strSql ="SELECT  title,authorname,userid FROM article"
  8. End Select
  9.  
now execute the query......fill a dataset...and bind your grid with this dataset......or altenatively you can use a datareader too...
Aug 23 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Jim | last post by:
I need some help getting started with a .NET web project for a commercial site. I am new to .NET and my understanding of some (but not all) of its concepts is a little sparse. I apologize for the...
0
by: Jim | last post by:
This si a repost, I apologize but perhaps my original inquiry got buried under all the usenet spam... I need some help getting started with a .NET web project for a commercial site. I am new to...
2
by: Joe | last post by:
Hi All, I am new to using the Access DB and I need some help if someone is able to give it to me. What I want to do is get the names of the columns of certain tables. Not the data in the table...
41
by: pb648174 | last post by:
In a multi-user environment, I would like to get a list of Ids generated, similar to: declare @LastId int select @LastId = Max(Id) From TableMania INSERT INTO TableMania (ColumnA, ColumnB)...
12
by: Lennart Anderson | last post by:
I'm having a MySQl table wih a lot of information. I want to present some main fields in a table on one page. Each record do, of course, have a unique ID. The presnted table will have one field as...
6
by: sgottenyc | last post by:
Hello, If you could assist me with the following situation, I would be very grateful. I have a table of data retrieved from database displayed on screen. To each row of data, I have added...
33
by: JamesB | last post by:
I am writing a service that monitors when a particular app is started. Works, but I need to get the user who is currently logged in, and of course Environment.UserName returns the service logon...
6
by: sathyashrayan | last post by:
Dear Group, Please look at the following demo link. http://www.itsravi.com/demo/new_pms/admin/addproject.php
2
by: rustyc | last post by:
Well, here's my first post in this forum (other than saying 'HI' over in the hi forum ;-) As I said over there: ... for a little side project at home, I'm writing a ham radio web site in...
10
by: Rahul Babbar | last post by:
Hi, I am getting the following error, while executing the simple insert script on a few tables. INSERT INTO <table_name>(<col1>) VALUES (1); DB2 SQL error: SQLCODE: -440, SQLSTATE: 42884,...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...

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.