What's new

Help .Net + MySQL - Showing only the inserted data of a particular User

Status
Not open for further replies.

Phrog

Forum Veteran
Elite
Joined
Jan 25, 2017
Posts
2,131
Reaction
1,379
Points
637
May ginagawa po kaming .net application about sa Inventory ng Com Lab
medyo minadali nalang po kasi kulang sa na po kami sa oras.

eto po yung Select Query ko para sa showing po ng data inserted by a particular user
Code:
Dim query As String = "SELECT * FROM pcdatabase WHERE pcdatabase.StudNum = '" & loginForm.txtStudentID.Text & "'"

then when I type on search box, nashoshow naman po uyng hinahanap ko, pero ang problema ko
po, after kong idelete yung text sa searhm pinapakita na din nya po yung data ng ibang user
1682758466151.png

Search function query
Code:
Dim query As String = "SELECT * FROM pcdatabase WHERE UnitID LIKE '" & txtSearch.Text & "%' OR StudNum LIKE '%" & loginForm.txtStudentID.Text & "'"
After searching:
1682758555618.png


na try ko na din po yung
Code:
 "%' OR StudNum LIKE '%" & txtSearch.Text & "'"
 

Attachments

Hello! It seems like you are encountering an issue with your Select Query in your .NET application. Based on your provided code, it seems like you are using the loginForm's textbox to filter the results based on the student number inputted by the user. However, when you delete the text in the search box, it continues to display the data of other users.

One possible solution to this problem is to add a condition to your query that checks if the search box is empty. You can do this by checking the length of the search box's text.

Here's an updated version of your query that includes this condition:

Code:
Dim query As String = ""
If txtSearch.Text.Length > 0 Then
    query = "SELECT * FROM pcdatabase WHERE StudNum = '" & loginForm.txtStudentID.Text & "' AND (Column1 LIKE '%" & txtSearch.Text & "%' OR Column2 LIKE '%" & txtSearch.Text & "%')"
Else
    query = "SELECT * FROM pcdatabase WHERE StudNum = '" & loginForm.txtStudentID.Text & "'"
End If

In this updated query, if the length of the text in the search box is greater than 0, it will include the search condition in the query. Otherwise, it will only filter the results based on the student number.

Please note that you would need to replace "Column1" and "Column2" with the actual column names of your table that you want to search for. Also, make sure to sanitize your inputs to prevent SQL injection attacks.
 
Thanks for the help I fixed it by adding the loadDataGrid() function after the search function
 
Status
Not open for further replies.

Similar threads

Back
Top