Question XML DataBase filter by date

Sparrow

Member
Joined
Jul 9, 2012
Messages
6
Programming Experience
1-3
Hi, I am working on a sms agent that dumps the message into a sql database and has another agent cheking it and then sending the sms.
I have put in a history view and the option to filter it with 2 datetimepicker but it doesn't seem to work. It just displays everything blank if I try to filter it.
The sms data for the local client is stored in a xml database

Here is the code to store it in a xml, to call the history and to filter it

send:




Private Sub btSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btSend.Click


Dim sendDate As Date
Dim ValidUser As Boolean
Dim HasPrice As Boolean
Dim numbers() As String
Dim names() As String
Dim sendSuccess As Boolean




If txtTo.Text = "" Then
MessageBox.Show("Please select a contact or enter a number", "Error")
txtTo.Focus()
Exit Sub
End If


If txtMessage.Text = "" Then
MessageBox.Show("Please enter a message", "Error")
txtMessage.Focus()
Exit Sub
End If


Try



numbers = Split(txtTo.Text, ",")


ValidUser = issendervalid(AccNr, GUserPassword)
HasPrice = getprice(AccNr, Password)


If ValidUser = True Then


If HasPrice = True Then


sendDate = DateTime.Now.ToShortDateString


Dim numcount As Integer = numbers.Count
Dim x As Integer = 0


Do While x < numcount
If numbers(x) <> "" Then


Dim name As String = getname(numbers(x))


names = Split(name, ",")


sendSuccess = sendsms(sendDate, numbers(x), txtMessage.Text)


If sendSuccess = True Then
'Add to xml history
frmViewSmsHistory.addxmltohistory(numbers(x), names(0), names(1), txtMessage.Text, sendDate)
'Add to database history
addtohistory(AccNr, sendDate, numbers(x), txtMessage.Text, Price)
End If

End If
x = x + 1
Loop


txtMessage.Text = ""
txtTo.Text = ""
MessageBox.Show("Message send successfull", "Success")


Else
MessageBox.Show("AccNr does not have price", "Error")
End If


Else
MessageBox.Show("Invalid Account Settings", "Error")
End If


Catch ex As Exception
MessageBox.Show("SmsOpera encountered an unknown error: " & ex.Message, "Error")
End Try


End Sub




load:




Private Sub LoadHistory()


dsHistory.Clear()


Try


If File.Exists(Application.StartupPath & "\xmlHistory.xml") = False Then
dsHistory.WriteXmlSchema(Application.StartupPath & "\xmlHistory.xml")
Else
dsHistory.ReadXmlSchema(Application.StartupPath & "\xmlHistory.xml")
End If


dsHistory.ReadXml(Application.StartupPath & "\xmlHistory.xml")


With dgHistory
.DataSource = dsHistory
.DataMember = "history"
End With




Catch myerror As Exception
MessageBox.Show("Error loading History: " & myerror.Message, "Error")


End Try
End Sub




filter:




Private Sub btExecute_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btExecute.Click




Dim name, surname, number As String
Dim startDate As Date
Dim endDate As Date
Dim nonqueryCommand As New MySqlCommand




name = lblValueName.Text
surname = lblValueSurname.Text
number = lblToValue.Text
startDate = Convert.ToDateTime(dtStartDate.Text)
endDate = Convert.ToDateTime(dtEndDate.Text)


startDate = startDate & " 00:00:00"
endDate = endDate & " 23:59:59"


Try
If File.Exists(Application.StartupPath & "\xmlHistory.xml") = False Then
dsHistory.WriteXmlSchema(Application.StartupPath & "\xmlHistory.xml")
Else
dsHistory.ReadXmlSchema(Application.StartupPath & "\xmlHistory.xml")
End If


Catch ex As Exception
MessageBox.Show("SmsOpera encountered an unknown error: " & ex.Message, "Error")
End Try




'Dim i As Integer
'Dim Nr As Integer
'Dim row As DataRow


Try


Dim view As DataView = New DataView
With view
.Table = dsHistory.Tables("History")
.AllowDelete = True
.AllowEdit = True
.AllowNew = True
.RowFilter = "Name = '" & name & "' and Surname = '" & surname & "' and Number = '" & number & "' and Date >= '" & startDate & "' AND Date <='" & endDate & "'"
.RowStateFilter = DataViewRowState.CurrentRows
.Sort = "Date ASC"
End With


dgHistory.DataSource = view




Catch ex As Exception
MessageBox.Show("Error deleting record: " & ex.Message, "Error")
End Try












End Sub

Can any body help me please?
 
Top Bottom