473,408 Members | 1,854 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.

Listing Records From DB

A P
I am new to VS.Net Professional but I am previously using Visual Interdev
6.0 . I want to list records from the database thru VS.Net . Its easy on
Visual Interdev but in VS .Net, I dont know how. Please help me!!!

Me
Nov 18 '05 #1
2 1096
You have two options, DataReader or DataSet. Here is a dataset
implementation in C#.

string connString = "YourConnStringHere";
string sql = "SELECT * FROM SomeTable";

SqlConnection conn = new SqlConnection(connString);
SqlCommand cmd = new SqlCommand(sql, conn);
SqlAdapter adapt = new SqlAdapter(cmd);
DataSet ds = new DataSet();

//optionally using statement here
try
{
conn.Open();
adapt.Fill(ds);
}
finally
{
if(conn.State=ConnectionState.Open)
conn.Close();

conn.Dispose();
}

DataGrid1.DataSource=ds;
DataGrid1.DataBind();

Very simple pattern. Easily adaptable.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*************************************************
Think outside the box!
*************************************************
"A P" <ap@textguru.ph> wrote in message
news:et**************@tk2msftngp13.phx.gbl...
I am new to VS.Net Professional but I am previously using Visual Interdev
6.0 . I want to list records from the database thru VS.Net . Its easy on
Visual Interdev but in VS .Net, I dont know how. Please help me!!!

Me

Nov 18 '05 #2
A P
Thanks for your reply. How about on VB? Not familiar of C# and I only
install VB.Net on my machine.

"Cowboy (Gregory A. Beamer)" <No************@comcast.netNoSpamM> wrote in
message news:uz**************@TK2MSFTNGP10.phx.gbl...
You have two options, DataReader or DataSet. Here is a dataset
implementation in C#.

string connString = "YourConnStringHere";
string sql = "SELECT * FROM SomeTable";

SqlConnection conn = new SqlConnection(connString);
SqlCommand cmd = new SqlCommand(sql, conn);
SqlAdapter adapt = new SqlAdapter(cmd);
DataSet ds = new DataSet();

//optionally using statement here
try
{
conn.Open();
adapt.Fill(ds);
}
finally
{
if(conn.State=ConnectionState.Open)
conn.Close();

conn.Dispose();
}

DataGrid1.DataSource=ds;
DataGrid1.DataBind();

Very simple pattern. Easily adaptable.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*************************************************
Think outside the box!
*************************************************
"A P" <ap@textguru.ph> wrote in message
news:et**************@tk2msftngp13.phx.gbl...
I am new to VS.Net Professional but I am previously using Visual Interdev
6.0 . I want to list records from the database thru VS.Net . Its easy on
Visual Interdev but in VS .Net, I dont know how. Please help me!!!

Me


Nov 18 '05 #3

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

Similar topics

1
by: Robert Neville | last post by:
The solution to my dilemma seems straight-forward, yet my mind has not been forthcoming with a direct route. My Project form has a tab control with multiple sub-forms; these distinct sub-forms...
1
by: Henry Stockbridge | last post by:
Hi, I am doing database documentation and run the procedure below to list the record count for each table in the database. The results in the immediate window only a partial listing of tables. ...
3
by: Alpha | last post by:
This is a Window based application. How do I get my combox listing to display in sorted order by DataMember? I inserted a blank row to the dataset table which is the datasrouce for the comboBox...
1
by: MLH | last post by:
Am having trouble with the filter property setting below. Would like to filter the listing to car makes beginning with "D". I'm blowing it on the filter spec somehow??? Sub OpenRecordsetX() ...
1
by: Chris | last post by:
I have a problem with grouping elements in my XSL. What I want to do is select all of the distinct SCE_CGPC records, then by the FSG_SNAM records for each SCE_CGPC and then again by MOA_NAME for...
2
by: vbsourcer | last post by:
Hello all could anybody tell me how I would be able to list information from a database using Two Fields from the Database ? I have this code which will populate the listbox with exactly what I want...
7
by: vbsourcer | last post by:
Listing two fields -------------------------------------------------------------------------------- Hello all could anybody tell me how I would be able to list information from a database using...
0
by: vbsourcer | last post by:
Hello all could anybody tell me how I would be able to list information from a database using Two Fields from the Database ? I have this code which will populate the listbox with exactly what I want...
13
BezerkRogue
by: BezerkRogue | last post by:
I am trying to get a listing of all records in a dataset to display in a table. I have tried several options I have found through research and get no where. Anyone have any easier ideas? Being new...
8
by: jmarcrum | last post by:
Hello all, i have a continuous form that displays about 1000 records and opens when I click a button. When the form opens, the user has the option of checking a checkbox that is located beside...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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.