The absolute basics of coding SQL Server in VB.net

  • 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 😉 !!!

  • 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.

  • 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


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • Lowell, thank you, that's a great help ...

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply