Sign up to the jQuery Grid Subscription list.
Showing posts with label sql. Show all posts
Showing posts with label sql. Show all posts

What is an optimizer in MS SQL server ?

Original post by sam.SQL at http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2995794&SiteID=1

The question:

What does mean by Optimizer in MS SQL ? What is it ?
How do you use it ? what are the benifits of use it ?

The accepted answer by Derekman:

The query optimizer is the component of SQL server that determines the most efficient way to execute a query based upon the distribution statistics and histograms maintained within sql server. When you pass a query to sql server the query is optimized based on the estimated "cost" of the query for the different possible ways to exeute the statement based on the table(s) and index(es) available. SQL Server query optimizer reviews the different options in which to execute the query and decides on the most efficient way based on overall cost. Most, but not all, queries are optimized automatically and you do not need to do anything to invoke query optimization. There are however "query hints" that allow you to over ride a query plan recommended by the optimizer.

Please review BOL and the below link for a more detailed explanation.

Best of Luck!!

How to add a new record (vb.net+SQL)

Original post by Jarge at http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2483346&SiteID=1

The question:

Ok i have an unbound text box

i also have a command button that does nothing.

I need to be able to have whatever i type into the text box to be entered into a table.

how can i do this?

for the record i know extremely little about VBA, i can copy and paste, and edit bits if im told what, when and where to edit but apart from that i'm useless.

Any help will be greatly appreciated.

The accepted answer by Spotty:

From what you said, you are leaving out real important points

A table, what sort of database are you using, does you applicable actually already use the database in any way already ?

What version of VB are you using ?

All these points determine a solution. The technology you are probably going to be using is called ADO.NET and you are going to be using a Command Object. A web search on ADO.NET + VB.NET + INSERT QUERY will probably reveal quite a few basic examples.


Something a simple as may work.
Dim con As SqlConnection
Try
con = New SqlConnection("Server=(local)\SQLEXPRESS;Initial Catalog=MyDatabase;Integrated Security=SSPI")
con.Open()
Dim cmd As New SqlCommand()
cmd.Connection = con
cmd.CommandText = "INSERT INTO Employee (FirstName) VALUES (@FirstName)"
' 2. Map parameters
cmd.Parameters.Add("@FirstName", SqlDbType.NVarChar, 10, "FirstName")
cmd.Parameters("@FirstName").Value = Textbox1.text
cmd.ExecuteNonQuery()
Finally
con.Close()
End Try