473,408 Members | 2,405 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,408 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 1233
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,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.