Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

The absolute basics of coding SQL Server in VB.net Expand / Collapse
Author
Message
Posted Wednesday, March 6, 2013 3:56 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Saturday, February 8, 2014 12:28 PM
Points: 22, Visits: 56
I am trying my best to get my head around SQL Server but seem to be going around in circles. Everything I google is either way too complicated for my simple means or else I find half a dozen different ways to do the same thing.

Can somebody please point me to a site, an article or a video where, in clear, plain, simple English, it explains the differences and the relationships between a datatable, a dataset, a dataadapter, a datastream & various other options I keep getting presented with ?!?

The sooner I can grasp the concepts and the differences, the sooner I can spend my time actually coding rather than asking questions !!!

Post #1427277
Posted Wednesday, March 6, 2013 5:39 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Thursday, June 20, 2013 7:32 AM
Points: 31, Visits: 50
This topic is .NET related since the only differences here are based on the processing of the query results. You should choose a simple method to get data back from sql server and get starting processing teh data. An easy way which is well described in millions of tutorials is using the technique with SqlDataAdapter, SqlCommand, SqlConnection and Datatables.

When the query returns a scalar result, most of this logic is not even needed because you can execute the query with an SqlCommand.ExecuteScalar() method and implicitly cast the result to the correct datatype. (int dbid = (int)cmd.ExecuteScalar();)

You can find more information on the various classes by googling "MSDN .net datatable" etc.
Post #1427327
Posted Wednesday, March 6, 2013 6:09 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 12:36 PM
Points: 12,881, Visits: 31,812
gary.p.heath (3/6/2013)
I am trying my best to get my head around SQL Server but seem to be going around in circles. Everything I google is either way too complicated for my simple means or else I find half a dozen different ways to do the same thing.

Can somebody please point me to a site, an article or a video where, in clear, plain, simple English, it explains the differences and the relationships between a datatable, a dataset, a dataadapter, a datastream & various other options I keep getting presented with ?!?

The sooner I can grasp the concepts and the differences, the sooner I can spend my time actually coding rather than asking questions !!!


a DataTable is a an object that mirrors a Table in SQL Server. it can have primary key, unique constraints, not null constraints, size constraints, defaults for columns, and even references(ie FK) to other Datatable.Columns. You would populate it with a query, so it is the object you use as a
container for the results of a query...so that query could be capturing the results from a table, query or view.

a dataSet is a container which can have zero to many DataTables. The image below is a Dataset with six DataTables in it.

A dataAdapter is the .NET object what is used to process the query from the server, and stuff it into the table. it is also used to sned any changes in the DataSet you've made, to propagate those changes back to the SQL Server.

A datastream is what is used when one of the columns in your datatable is binary(image, varbinary for example); it's just handling the results in a special way, is how i would explain it.

you can create a Dataset.xsd in your project, and with the server explorer, drag and drop tables you plan to use in your query. this can help during design time.



Lowell

--There is no spoon, and there's no default ORDER BY in sql server either.
Actually, Common Sense is so rare, it should be considered a Superpower. --my son
Post #1427337
Posted Wednesday, March 6, 2013 7:43 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Saturday, February 8, 2014 12:28 PM
Points: 22, Visits: 56
Lowell, thank you, that's a great help ...
Post #1427409
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse