Michael,
Thank you for the information! I have a problem because I am not sure how to put this on the following ASP.Net page. I have tried using the function you have provided me with, but I have been unsuccessful due to OleDbConnection() and OleDbCommand()
. I am new at using SQL Server on an ASP.net page. Please look at the code below:
<%@ Page Language="VB" Debug="true" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SQLClient" %>
'---------------------------------------------
' name: BindDataGrid()
'---------------------------------------------
Sub BindDataGrid()
Dim strConnect As String
Dim objConnect As New OleDbConnection()
Dim objCommand As New OleDbCommand()
Dim strSQL as String
Dim dtaMusic As New OleDbDataAdapter()
Dim dtsMusic As New DataSet()
'Build connection object
strConnect (I am not sure what I should do).
objConnect.ConnectionString = strConnect
objConnect.Open()
'Start SQL statement
strSQL = "Select * From Spa2
'Add Order By
strSQL = strSQL & " Order By SpaStoreName"
Trace.Warn ("strSQL = " & strSQL)
'Set the Command Object properties
objCommand.Connection = objConnect
objCommand.CommandType = CommandType.Text
objCommand.CommandText = strSQL
'Point the DataAdapter object at a Command object to work with
dtaMusic.SelectCommand = objCommand
'Get the data from the database and
'put it into a DataTable object named dttMusic in the DataSet object
dtaMusic.Fill(dtsMusic, "dttMusic")
'Bind the DataGrid
dtgMusic.DataSource = dtsMusic
dtgMusic.DataBind()
End Sub
Can someone please help me figure out how to use this with SQL Server?