It is standard set to true, i didn't change it. All my code is:
Dim connectie As New SqlClient.SqlConnection("Server=" + getsqlserver() +
";Initial Catalog=" + getsqlcatalog() + ";Trusted_Connection=True")
Dim strSQL As String
Dim ds As New DataSet
Dim whereSQL As String = "where "
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If Not Page.IsPostBack Then
InlezenConfig()
End If
Dim strsqlDocType As String = "select distinct type from
TBL_Bestanden_Zoeken"
Dim da As New SqlClient.SqlDataAdapter(strsqlDocType, connectie)
da.Fill(ds, "doctype")
Dim row As DataRow
row = ds.Tables("doctype").NewRow
row("Type") = "Selecteer een type"
ds.Tables("doctype").Rows.Add(row)
ddlDocType.DataSource = ds.Tables("doctype")
ddlDocType.DataBind()
ddlDocType.SelectedIndex = ds.Tables("doctype").Rows.Count - 1
lblZoeken.Visible = False
dtgZoekResultaten.Visible = True
End Sub
'Knop Velden leegmaken => alle zoekvelden leegmaken of niets geselecteerd
Private Sub btnreset_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnreset.Click
Me.txtdocbedrag.Text = ""
Me.txtdocdatumVan.Text = ""
Me.txtdocdatumTot.Text = ""
Me.txtdocnr.Text = ""
Me.txtklantnaam.Text = ""
Me.txtklantnr.Text = ""
End Sub
Private Sub btnzoeken_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnzoeken.Click
Dim i As New Integer
'documentnummer ingevuld
If Not (txtdocnr.Text = "") Then
whereSQL += "docnr like '" & txtdocnr.Text & "' and "
End If
'klantnummer ingevuld
If Not (txtklantnr.Text = "") Then
whereSQL += "klnr like '" & txtklantnr.Text & "' and "
End If
'klantnaam ingevuld
If Not (txtklantnaam.Text = "") Then
Dim klantnaam As String = Trim(txtklantnaam.Text)
Do While (InStr(klantnaam, " ") > 0)
klantnaam = Microsoft.VisualBasic.Left(klantnaam, InStr(klantnaam,
InStr(klantnaam, " ") - 1)) + _
Microsoft.VisualBasic.Right(klantnaam, InStr(klantnaam, Len(klantnaam) -
InStr(klantnaam, " ")))
Loop
If Microsoft.VisualBasic.Right(klantnaam, 1).Equals("*") Then
If Microsoft.VisualBasic.Left(klantnaam, 1).Equals("*") Then
whereSQL += "klnaam like '%" & klantnaam & "%' or klnaam like '%" &
txtklantnaam.Text & "%' and "
Else
whereSQL += "klnaam like '" & klantnaam & "%' or klnaam like '" &
txtklantnaam.Text & "%' and "
End If
ElseIf Microsoft.VisualBasic.Left(klantnaam, 1).Equals("*") Then
whereSQL += "klnaam like '%" & klantnaam & "' or klnaam like '%" &
txtklantnaam.Text & "' and "
Else
whereSQL += "klnaam like '" & txtklantnaam.Text & "' or klnaam like '" &
klantnaam & "' and "
End If
End If
'document datum ingevuld
If Not (txtdocdatumTot.Text = "") Then
If Not (txtdocdatumVan.Text = "") Then
whereSQL += "convert(datetime,datum,101) between '" & txtdocdatumVan.Text &
"' and '" & CDate(txtdocdatumTot.Text) & "' and "
Else
lblDatum.ForeColor = System.Drawing.Color.Red
End If
ElseIf Not (txtdocdatumVan.Text = "") Then
whereSQL += "convert(datetime,datum,101) = '" & CDate(txtdocdatumVan.Text) &
"' and "
End If
'document bedrag ingevuld
If Not (txtdocbedrag.Text = "") Then
Select Case ddlBedrag.SelectedIndex
Case 0
Case 1
strSQL += "bedrag > '" & Double.Parse(txtdocbedrag.Text) & "' and "
Case 2
strSQL += "bedrag >= '" & Double.Parse(txtdocbedrag.Text) & "' and "
Case 3
strSQL += "bedrag < '" & Double.Parse(txtdocbedrag.Text) & "' and "
Case 4
strSQL += "bedrag <= '" & Double.Parse(txtdocbedrag.Text) & "' and "
Case 5
strSQL += "bedrag = '" & Double.Parse(txtdocbedrag.Text) & "' and "
Case 6
strSQL += "bedrag >= '" & Double.Parse(txtdocbedrag.Text) & "' and bedrag <
'" & Double.Parse(txtBedragTot.Text) & "' and "
End Select
End If
'documenttype ingevuld
i = 0
'While (i < ds.Tables("doctype").Rows.Count)
'If (ddlDocType.SelectedIndex = i) Then
whereSQL += "type like '" & ddlDocType.SelectedValue & "' and "
'i = ds.Tables("doctype").Rows.Count
'End If
'i += 1
'End While
'laatste " and " van de string knippen
whereSQL = Microsoft.VisualBasic.Left(whereSQL, whereSQL.Length - 5)
'strSQL maken
strSQL = "select Id, docnr, klnr, klnaam, datum, bedrag, type from
TBL_Bestanden_Zoeken " & whereSQL & " order by docnr"
If ((txtdocnr.Text = "") And (txtklantnr.Text = "") And (txtklantnaam.Text =
"") And (txtdocdatumVan.Text = "") And (txtdocdatumTot.Text = "") And
(txtdocbedrag.Text = "") And (txtBedragTot.Text = "") And Not
(ddlDocType.SelectedIndex = 0)) Then
lblZoeken.Visible = True
strSQL = ""
dtgZoekResultaten.Visible = False
Else
'dataset opvullen
Dim da2 As New SqlClient.SqlDataAdapter(strSQL, connectie)
da2.Fill(ds, "bestanden")
If (ds.Tables("bestanden").Rows.Count <> 0) Then
dtgZoekResultaten.DataSource = ds.Tables("bestanden").DefaultView
DataBind()
Else
lblZoeken.Text = "Er is niets gevonden"
lblZoeken.Visible = True
dtgZoekResultaten.Visible = False
End If
End If
End Sub
Private Sub dtgZoekResultaten_PageIndexChanged(ByVal source As
System.Object, ByVal e As
System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles
dtgZoekResultaten.PageIndexChanged
dtgZoekResultaten.CurrentPageIndex = e.NewPageIndex
dtgZoekResultaten.DataBind()
End Sub
End Class