Last post Sep 03, 2019 12:19 PM by E.RU
Sep 03, 2019 11:02 AM|E.RU|LINK
I have the following code which works prefectly, but now I would like to add an extra condition for returning the data. At present I have two textboxes in which the user enters a value and presses the summit button and if those values are in the sql database
they are returned in a gridview format onscreen.
I would like to add another textbox which acts like a third criteria. The issue I have though is the column is a date. in the SQL database it is in thf form '2018-12-01 00:00:00'. however I would like the user to be able to enter the date in the form MM/YYY
into the textbox.
How would I go about doing this. Many thanks
Dim conConn As SqlConnection = Nothing
Dim comComm As SqlCommand = Nothing
Dim adpAdap As SqlDataAdapter = Nothing
Dim Dst As DataSet = New DataSet()
comComm = New SqlCommand
conConn = New SqlConnection(GblSqlCon)
.Connection = conConn
.CommandType = CommandType.Text
.CommandText = "SELECT * FROM tbl_x WHERE Ttl >= 50 and (Cde= @Cde) AND (ID = @ID) " ' AND (dte = @dte)"
' .Parameters.AddWithValue("@dte", dte)
adpAdap = New SqlDataAdapter(comComm)
GridView1.DataSource = Dst.Tables("tbl")
Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Call GetDataBase1(txtbx1.Text, txtbx2.Text, txtbx3.Text)
Sep 03, 2019 12:16 PM|paindaasp|LINK
Would converting your textbox into the first day of the month work?
Dim mmYYYY() As String = txtDte.Text.Split("/")
Dim dte As String = mmYYYY(0) & "/01/" & mmYYYY(1)
Sep 03, 2019 12:19 PM|E.RU|LINK
I just solved my probling using this in my sql statement
thankyou for your reply.