Visual Basic Code , VB.NET Code, VB Code
  Home   :  Code   :  Forums   :  Submit   :  Mailing List   :  About   :  Contact
A1VBCode Forums
Home      Members   Calendar   Who's On
Welcome Guest ( Login | Register )
      

Home » Visual Basic (VB 4/5/6) » Internet/Communications Programming » How to Update using ADODB in Classic ASP


How to Update using ADODB in Classic ASPExpand / Collapse
Author
Message
Posted 9/9/2008 7:32:29 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 9/9/2008 7:30:32 AM
Posts: 2, Visits: 3
Hi All

Generally we are using the following code to update using ADODB

sql = "SELECT * FROM customers WHERE CustomerID=" + custID;
recordSet.Open(sql, connection, 1, 2);
 recordSet("FirstName") = firstName;
 recordSet("MiddleInitial") = middleInitial;
recordSet.Update();
recordSet.Close();
But, we are facing sql injection problem. so what we can't pass value directly to query. So I have changed to
var sqlcmd =  Server.CreateObject("ADODB.Command");
      sqlcmd.CommandText = sql;
      sqlcmd.CommandType = 1;
      sqlcmd.Parameters.Append(sqlcmd.CreateParameter("@column1",200,1 ,10,custID));

My Doubt is, How to update sqlcmd using recordset. can you please explain?


.Net Developer
CompIndia Infotech P Ltd
Tiruapti.
http://www.compindia.com

Post #25669
Posted 9/9/2008 8:21:59 AM
Forum God

Forum GodForum GodForum GodForum GodForum GodForum GodForum GodForum God

Group: Forum Members
Last Login: Yesterday @ 4:38:01 AM
Posts: 886, Visits: 5,287
My Doubt is, How to update sqlcmd using recordset. can you please explain?

I don't think you can.

You have a few strategies to deal with sql injection. The steps I would take are

  1. Change your queries to stored procedures - by doing that it will ensure the datatype and size are correct. For example you can set the size of Middle Inital to 1. There isn't much that can be done with sql injection if you can only use 1 character.
  2. Validate your inputs on the client before submitting the form - This will catch problem entries before they leave the browser.
  3. Validate your inputs on the server before the stored procedure is run - You also have to make sure the input have not been intercepted and tampered with.
Post #25671
« Prev Topic | Next Topic »


Reading This TopicExpand / Collapse
Active Users: 1 (1 guest, 0 members, 0 anonymous members)
No members currently viewing this topic.
Forum Moderators: Brian, Peter

PermissionsExpand / Collapse

All times are GMT -5:00, Time now is 11:37pm