Hi Guys need your help on this :(
Basically I am developing a web crawler so once the html source is converted to plaintext in a textbox, i intent to save it in dB.
But the dB seems to be having trouble excepting some characters into the
table and throwing up errors like shown below where database 'our' does
not exist and it seems to be picking up random db names when i try to
save source from different pages.
Please advice as to how I could avoid this?
An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll
Additional information: Incorrect syntax near 'll'.
Could not locate entry in sysdatabases for database 'our'. No entry found with that name. Make sure that the name is entered correctly.The thread '<Thread Ended>' (0x1050) has exited with code 0 (0x0).
Here is my code for store procedure:
Dim con As New SqlConnection("Data Source=KJSINGH-PC\SQLEXPRESS;Initial Catalog=ForumCrawl;Integrated Security=True")
Dim com As SqlCommand = Nothing
Dim queryResult As Integer
Dim dateToDisplay As DateTime = DateTime.Now
con.Open()
com = New SqlCommand("SELECT COUNT(*) FROM [search_result] WHERE URL = '" & tb_URL.Text & "' AND page_content = '" & tb_Parse.Text & "'", con)
queryResult = com.ExecuteScalar()
con.Close()
If queryResult = 0 Then
con.Open()
com = New SqlCommand("INSERT INTO [search_result] (URL, page_content, date_created) VALUES ('" & tb_URL.Text & "','" & tb_Parse.Text & "', '" & dateToDisplay.ToString("yyyy-MM-dd hh:mm:ss") & "')", con)
com.ExecuteNonQuery()
con.Close()
Else
MsgBox("Data alread exists")
End If