![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I have a client/server app. that uses a windows service for the server and asp.net web pages for the client side. My server class has 3 methods that Fill, Add a new record and Update a record. The Fill and Add routines work as expected but unfortunately the update request falls at the 1st hurdle. I pass two params to the remote(server) method for the update, one is the unique ID and the other is a string that is the name of the table in the database. See code below. I need the SelectedRow method to return a datarow that will then populate textbox's on another page. When the method is called I get an 'internal system error.....please turn on custom errors in the web.config file on the server for more info.(unfortunately my server is not s web server so I don't have a web.config file!!). |
|
Dim intRow As Integer = CInt(Request.QueryString("item")) strDiscipline = Request.QueryString("discipline") drEdit = hsc.SelectedRow(intRow, strDiscipline) <<Call the remote method Dim strQuery As String = "SELECT * FROM " & strDiscipline & _ " WHERE CallID=" & id |
#3
| |||
| |||
|
|
Phil (Phil (AT) nospam (DOT) com) writes: I have a client/server app. that uses a windows service for the server and asp.net web pages for the client side. My server class has 3 methods that Fill, Add a new record and Update a record. The Fill and Add routines work as expected but unfortunately the update request falls at the 1st hurdle. I pass two params to the remote(server) method for the update, one is the unique ID and the other is a string that is the name of the table in the database. See code below. I need the SelectedRow method to return a datarow that will then populate textbox's on another page. When the method is called I get an 'internal system error.....please turn on custom errors in the web.config file on the server for more info.(unfortunately my server is not s web server so I don't have a web.config file!!). I don't really have an idea, but the error message does not look like it comes from SQL Server. Maybe you should try an ADO .Net group. Dim intRow As Integer = CInt(Request.QueryString("item")) strDiscipline = Request.QueryString("discipline") drEdit = hsc.SelectedRow(intRow, strDiscipline) <<Call the remote method Dim strQuery As String = "SELECT * FROM " & strDiscipline & _ " WHERE CallID=" & id I don't know what this Request.QueryString implies, but this is any sorr of user input, you have a major hole here. What if the user specifies a table that does not exist? What if he specifies "tbl; DROP DATABASE important; --"? This is called SQL injection, and is a popular way for intruders to get access to things they should have access to. I don't know why you pass the table name as a parameter, but it's not likely to be good design. For the CallID you should in any case use a parameter: Dim strQuery As String = "SELECT * FROM " & strDiscipline & _ " WHERE CallID=@id" cmdSelect.AddParameter(@id, SqlInt, Id) (With all reservations for the exact syntax.) Parameterizing your SQL statements protects you from SQL injection. -- Erland Sommarskog, SQL Server MVP, esquel (AT) sommarskog (DOT) se Books Online for SQL Server SP3 at http://www.microsoft.com/sql/techinf...2000/books.asp |
#4
| |||
| |||
|
|
The QueryString property of the HTTPRequest class adds two, lets call them parameters are passed from the calling page. These params are 'hard-coded' items in a dropdownlist and selected row from a datagrid. So, I utterly agree with your concerns regarding SQL injection but 'hopefully' in this instance I'm ok....!!! |
![]() |
| Thread Tools | |
| Display Modes | |
| |