Click here to Skip to main content
15,889,200 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am creating a school management system. And I want user to type a particular name in a textbox to display the student's exams records into the Crystal Report.
But my code isn't working.

What I have tried:

Try

Sql = "select * from Student where Fullname = '" & txtname.Text &'""
Connect()
cmd = New OleDbCommand (Sql,con)
dr = cmd. ExecuteReader ()

While dr.Read
CrystalReportViewer1.Rows.Add
End while

Catch ex As Exception
End Try
Posted
Updated 19-Feb-16 2:19am
Comments
Richard Deeming 19-Feb-16 8:42am    
Your code is vulnerable to SQL Injection[^].

NEVER use string concatenation to build a SQL query. ALWAYS use a parameterized query.

1 solution

Your code just adds rows to the CrystalReportViewer1, it does not add any data to the added row so you get a blank row for each record from the database.
 
Share this answer
 
Comments
Richmond Boateng 19-Feb-16 8:26am    
Please what do I do?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900