473,667 Members | 2,749 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

2 New Member
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 1745
scripto
143 New Member
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.Tex t
cmd.CommandText = txt
dim da as SqlDataAdapter = New SqlDataAdapter( )
dim ds as DataSet = new DataSet()
da.Fill(ds, "txtResults ")

'bind to a datagrid
dgrid.DataSourc e = ds
dgrig.DataMembe r = "txtResults "
dgrid.DataBind( )
Oct 17 '06 #2
DoubleShot
2 New Member
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.Tex t
cmd.CommandText = txt
dim da as SqlDataAdapter = New SqlDataAdapter( )
dim ds as DataSet = new DataSet()
da.Fill(ds, "txtResults ")

'bind to a datagrid
dgrid.DataSourc e = ds
dgrig.DataMembe r = "txtResults "
dgrid.DataBind( )
Oct 17 '06 #3

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

Similar topics

4
292
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 are predefined editor classes, plugins for interaction with source code control systems etc...
2
1504
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 directly from the MS-DOS prompt. I have read about a Visual Studio IDE configuration so that the console window doesn't simply disappear when the program has finished running, but it seems to be a default configuration and is not explained how to...
3
2405
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 projects, I was using log4net (with varying degrees of success). Does Visual Studio 2005 have built in logging support? (I haven't been able to find this information in the documentation.)
2
1150
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, so I installed it. When I converted the project I was warned that ASP 2.0 would be needed. I tried to install the webservice on a test webserver running Win2k. It has ASP 1.1 installed. I looked on the Microsoft site and although
0
914
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 questin about. In Delphi, by default, when you compile your project, you get all the .aspx files and a myproject.dll in the bin directory. Each time i compile, the .dll is recompiled, but it still has the same name. The advantage with this, is that...
0
2551
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 ActiveDocument.Selection.Text = "//" + ActiveDocument.Selection.Text
0
1098
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 ADODC to by database and on the Form was a TextBox , a Button and a DataGrid. The user was writting in the TextBox and when he pressed th Button in the DataGrid was able to see the results The code I was using was this: Private Sub...
4
1544
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
4863
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 in msvsmon.exe on the remote machine, however, the client box with visual studio displays error: "Unable to connect to the mricosoft visual studio remtoe debugging monitor named 'the box name' the micorosft visual studio remote debugging monitor...
4
12689
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 place a stop directive in the code which ends up doing the same thing. The problem with this is that you can't debug browser side Javascript in the same debug run. You get a "The breakpoint will not currently be hit. The document is not loaded." if...
0
8458
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8366
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8888
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8565
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6206
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4372
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2779
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2017
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1779
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.