I am using the following code to bind a datalist to a query from an SQL database:
How do I implement the following code to I replace the Query string with this code:
I know its probably pretty simple, but I have tried plenty of solutions but can get none of them to bind correctly.
Thanks
Code:
Dim Query As String = "select * from Customers"
objcn = New SqlConnection(ConfigurationManager.ConnectionStrings("NorthwindConnectionString").ConnectionString)
objAd = New SqlDataAdapter(Query, objcn)
objDs = New DataSet
If Not IsPostBack Then
objAd.Fill(objDs)
lblRecordCount.Text = objDs.Tables(0).Rows.Count.ToString
End If
objAd.Fill(objDs, Convert.ToInt32(lblCurrentIndex.Text), Convert.ToInt32(lblPagesize.Text), "tblEmp")
dlCustomers.DataSource = objDs.Tables("tblEmp").DefaultView
dlCustomers.DataBind()
How do I implement the following code to I replace the Query string with this code:
Code:
Dim strConnString As String = ConfigurationManager.ConnectionStrings("NorthwindConnectionString").ConnectionString
Dim con As New SqlConnection(strConnString)
Dim cmd As New SqlCommand()
cmd.CommandType = CommandType.StoredProcedure
cmd.CommandText = "spGetCustomers"
cmd.Connection = con
I know its probably pretty simple, but I have tried plenty of solutions but can get none of them to bind correctly.
Thanks