473,413 Members | 1,802 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,413 software developers and data experts.

SQL Select Problem with Visual Studio C# 2003--HELP!

HELP!

I am trying to write a database app with three tables. I have figured out how to connect to my database with oledbconnect. From there I am confused as to how to get a select command to work. I have found plenty of info on selecting data from one table using the SQL QUERY option. I do not want to select from one table. I want to select from two tables, for example:
select tbl1.name, tbl2.address
from table1 tbl1, table2 tbl2
where
tbl1.id = tbl2.id

This should not be so difficult, but it is. I am not certain if I have to do something with the dataset, data-adapter or what. I would like someone out there to give me a step-by-step as to what I need to click-and-or-drag when setting up the connection, dataset, etc. Thanks ahead of time for the expertise!
Oct 17 '06 #1
2 1740
scripto
143 100+
I will assume that you know how to create the SqlConnection1


dim txt as string
txt = "select tbl1.name, tbl2.address
from table1 tbl1, table2 tbl2
where tbl1.id = tbl2.id"

dim cmd as SqlCommand = SqlConnection1.CreateCommand
cmd.CommandType = CommandType.Text
cmd.CommandText = txt
dim da as SqlDataAdapter = New SqlDataAdapter()
dim ds as DataSet = new DataSet()
da.Fill(ds, "txtResults")

'bind to a datagrid
dgrid.DataSource = ds
dgrig.DataMember = "txtResults"
dgrid.DataBind()
Oct 17 '06 #2
I think I can figure out the SqlConnection, though I am using an Access database. I am also working in C#. But I will try what you have here using VB for C#. I assume it is close to the same.
Thanks
I will assume that you know how to create the SqlConnection1


dim txt as string
txt = "select tbl1.name, tbl2.address
from table1 tbl1, table2 tbl2
where tbl1.id = tbl2.id"

dim cmd as SqlCommand = SqlConnection1.CreateCommand
cmd.CommandType = CommandType.Text
cmd.CommandText = txt
dim da as SqlDataAdapter = New SqlDataAdapter()
dim ds as DataSet = new DataSet()
da.Fill(ds, "txtResults")

'bind to a datagrid
dgrid.DataSource = ds
dgrig.DataMember = "txtResults"
dgrid.DataBind()
Oct 17 '06 #3

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

Similar topics

4
by: DanTheMan | last post by:
Hi! I would like to make my own ide with Visual Studio. Are there any libraries that can help me out on the way? Something similar to Eclipse framework, that can speed this up? In Eclipse there...
2
by: zatenay | last post by:
Hey, I'm a beginner with Visual Studio and C++, so I've the following problem : when I run a program with Debug-Start without debugging command, I can't see the output, so I have to run it...
3
by: marmaxx | last post by:
I am currently making the transition from Visual Studio .NET 2003 to Visual Studio 2005, and I am looking for suggestions regarding how to implement an exception logging scheme. In my previous...
2
by: acteon | last post by:
Hello, I recently updated a web service project that was originally created by a consultant with Visual Studio 2003 with Visual Studio 2005. The .MSI file told me I needed the 2.0 framework,...
0
by: jostein.solstad | last post by:
Hi I have been working with Delphi to create asp.net sites so far. I am now trying my luck with Visual Studio. But there are some differences in compiling, publishing my site that i have a...
0
by: bernhard.nowara | last post by:
Hello, I found a bug in Visual Basic used with Visual Studio Macros (Microsoft Visual Studio 2005 + SP1). Description: If I apply the simple Visual Basic statement...
0
by: mandrax7 | last post by:
I used Visual Studio 6 and I had made a simple program to access a SQL 2000 database, now I'm trying to do the same thing with Visual studio 20005, but.....nothing works. I used to connect with...
4
by: Daniel | last post by:
How to take an IE rendered screenshot of a website with visual studio .net 2002 or visual stuido .net 2003? I can't install visual studio .net 2005 on this computer.
1
by: DR | last post by:
What ports do i need to unblock on client and server (running msvsmon.exe) to debug remotely from my client box with visual studio 2005 pro? When I attach to remote process a connection shows up...
4
by: =?Utf-8?B?TWlrZSBHYWxl?= | last post by:
VS 2008 initially didn't debug classic ASP. SP1 fixes this in some ways. You can debug if you select the debug option to "Start Without Debugging, then either attach the debugger manually or...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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,...

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.