PseudZ
Expert Member
- Joined
- May 28, 2008
- Messages
- 1,235
Good Day
I have searched this forum and Googled as well, but nothing is helping much.
I'm having to design a web application for a veterinarian, it just holds records of animals and owners and such. It's a varsity project.
Up until now I have not run into problems. I'm using Visual Web Developer and can create new records, edit and delete them.
The problem comes in when I wanted to add a search option, to search animal names in the database. I have a search text box and a search button, but when I enter an animals name and click search it crashes and says it cant open the database.
I'm just wondering if anyone has any ideas how I could go about getting the search function working?
Not to sure if I should of coded it in the search button, or as vbscript.
Any help would be appreciated.
Thanks
I have searched this forum and Googled as well, but nothing is helping much.
I'm having to design a web application for a veterinarian, it just holds records of animals and owners and such. It's a varsity project.
Up until now I have not run into problems. I'm using Visual Web Developer and can create new records, edit and delete them.
The problem comes in when I wanted to add a search option, to search animal names in the database. I have a search text box and a search button, but when I enter an animals name and click search it crashes and says it cant open the database.
I'm just wondering if anyone has any ideas how I could go about getting the search function working?
Code:
Protected Sub SearchButton_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim strDBConnection As String = "server=(local);database=IPGDatabase.mdf;user id=Craig;password=Pwd;connection reset=false;connection lifetime=5;Trusted_Connection=Yes;"
Dim dbConnection As Data.SqlClient.SqlConnection
Dim SearchTextBox As String
dbConnection = New Data.SqlClient.SqlConnection(strDBConnection)
Dim strSelectSql As String = "Select * from [IPGDatabase.mdf].[CRAIG\Craig].RecordsTable WHERE AnimalName = '" & SearchTextBox & "' ;"
dbConnection.Open()
Dim selectSqlCommand As Data.SqlClient.SqlCommand = New Data.SqlClient.SqlCommand(strSelectSql, dbConnection)
Dim sqlData As Data.SqlClient.SqlDataAdapter = New Data.SqlClient.SqlDataAdapter(selectSqlCommand)
Dim dsSelectData = New Data.DataSet()
sqlData.Fill(dsSelectData)
End Sub
Not to sure if I should of coded it in the search button, or as vbscript.
Any help would be appreciated.
Thanks