17.06.2013 Views

Beginning Microsoft SQL Server 2008 ... - S3 Tech Training

Beginning Microsoft SQL Server 2008 ... - S3 Tech Training

Beginning Microsoft SQL Server 2008 ... - S3 Tech Training

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Dim strCommand2 As String = “DROP TABLE Foo”<br />

Dim cnMyConn As New SqlClient.SqlConnection(strConnect)<br />

‘ “Open” the connection (this is the first time it actually<br />

‘ contacts the database server)<br />

cnMyConn.Open()<br />

‘ Create the command object now<br />

Dim sqlMyCommand As New SqlClient.SqlCommand(strCommand, cnMyConn)<br />

‘ Execute the command<br />

sqlMyCommand.ExecuteNonQuery()<br />

Console.WriteLine(“Table Created”)<br />

Console.WriteLine(“Press enter to continue (you can go check to make sure<br />

that it’s there first)”)<br />

Console.ReadLine()<br />

End Sub<br />

End Module<br />

‘ Change the command<br />

sqlMyCommand.CommandText = strCommand2<br />

sqlMyCommand.ExecuteNonQuery()<br />

Console.WriteLine(“It’s gone”)<br />

Console.WriteLine()<br />

Console.WriteLine(“Press any key to continue...”)<br />

Console.ReadKey()<br />

‘ Clean up<br />

cnMyConn.Close()<br />

A Brief Word on LINQ<br />

Appendix B: Very Simple Connectivity Examples<br />

LINQ is, as I write this, “all the rage” so to speak. For the rare few that haven’t heard of LINQ, it is a<br />

new (or, more accurately, a new attempt at an) access method based on the notion of homogeneous data<br />

sources. LINQ has its own query language — one that is very similar to <strong>SQL</strong>, and yet different enough to<br />

create no small degree of work when trying to convert between the two.<br />

While LINQ certainly has, and will likely continue for at least a while to have a lot of momentum as the<br />

new way of accessing data, I remain something of a skeptic. Don’t get me wrong. LINQ has some cool<br />

things to offer, but I’ve seen LINQ-type data access notions come and go many times over the years, so<br />

I’ve been trained to question the staying power of such models.<br />

655

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!