working with datagrid

I

Itsme

Hi all,

This is my first asp application, and I am looking for a help to
populate a datagrid which should get populated from a sqlstring that
calls function. The code:

Sub FillDatagribWithRecords()
Dim tbxstart As String = txtStartDate.Text
Dim startdate As Date

Dim tbxend As String = txtEndDate.Text
Dim enddate As Date

Dim PhoneNumber As String
PhoneNumber = ddlPhoneNumber.SelectedValue


'Response.Write(& ddlPhoneNumber &)


If IsDate(tbxstart) And IsDate(tbxend) Then
txtStartDate.Text = Format(tbxstart, "dd/mm/yyyy")
startdate = CDate(tbxstart)

txtEndDate.Text = Format(tbxend, "dd/mm/yyyy")
enddate = CDate(tbxend)

Try
Dim gridds As DataSet
Dim myConnection As SqlConnection
Dim GridSelectString As String

gridds = New DataSet
GridSelectString = "SELECT SUBSTRING(CAST(calldate AS
VARCHAR(20)), 1, 11) AS CallDate," & _
" SUBSTRING(CAST(calldate AS
VARCHAR(20)), 12, 13) AS CallTime," & _
" PhoneNumber, minutes,
calldescription, charge " & _
" FROM
voipcalls.dbo.fw_fnVOIPGetCustCallHistory('" & PhoneNumber & "', " & _
"'" & startdate & "', '" &
enddate & "', 0, -1)"
Response.Write("PhoneNumber")

myConnection = New
SqlConnection("Server=192.168.225.8;Database=Wiband;uid=Wiband;password=optiplex")
myConnection.Open()
Dim GridDA As New SqlDataAdapter(GridSelectString,
myConnection)
GridDA.Fill(gridds, "DataGridRecords")
myConnection.Close()
GridDA.Dispose()
Me.GRCallHistory.DataMember = GridSelectString
Me.GRCallHistory.DataSource = gridds

gridds.Dispose()

Catch ex As Exception
MsgBox(ex.ToString)
End Try

Else
Response.Write("Please enter start date and end date")
End If

End Sub


Any help would be appreciated.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top