473,549 Members | 2,935 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

parameterized querry in .net

41 New Member
i came across a article, where it was mentioned if we want a dynamic querry to fire then use parameterized querry
e.g.
string inputcity=textb ox.text;
SqlCommand cmd = new SqlCommand("sel ect * from Customers where city=
'" + inputCity + " ' ";
Don't ever build a query this way!


as this leads to hacking.
instaed do it like this:

SqlCommand cmd = new SqlCommand("sel ect * from Customers where city = @City", conn);
SqlParameter param = new SqlParameter();
param.Parameter Name = "@City";
param.Value = inputCity;
cmd.Parameters. Add(param);

do u really think hacking problem can b solved using parameterized querry.If yes plz tell me, how hacking prob is solved .

thnx in advance
Feb 26 '08 #1
2 1447
debasisdas
8,127 Recognized Expert Expert
Parameterized query is Ok but i don't understand how that is related to hacking .
Feb 26 '08 #2
dipalichavan82
41 New Member
in above ecample author said case1 is wrong way of implementation because:


The input variable, inputCity, is typically retrieved from a TextBox control on either a Windows form or a Web Page. Anything placed into that TextBox control will be put into inputCity and added to your SQL string. This situation invites a hacker to replace that string with something malicious. In the worst case, you could give full control of your computer away.

but i think same chances r there when we use parameterized querry.
Feb 26 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
3188
by: Eric Kincl | last post by:
Hello, I have an array of data in PHP. I would like to insert each member of the array into it's own row in SQL. The array is of variable length, so it would have to be dynamic code. How would I go about this? Would I stick the SQL querry generation and actual querry into a while loop? This would generate a lot of traffic between the SQL...
0
1598
by: Costa Lino | last post by:
Hi All, I have a DataSet with xml file and I want to make a querry like this DataView dv = new DataView(mytable); dv.RowFilter = " Impression < ( MaxImpressions) "; Impression et MaxImpressions is collumns in my table the same querry access database is working but her is return 0
1
6052
by: gary b | last post by:
Hello When I use a PreparedStatement (in jdbc) with the following query: SELECT store_groups_id FROM store_groups WHERE store_groups_id IS NOT NULL AND type = ? ORDER BY group_name
7
3656
by: Wayne Wood | last post by:
i posted this problem on microsoft.public.excel.programming, but there's no one replied till now. because this issue is time critical, i put it here to try my fortune :) ------------------------------------------------------------------------ I am just a fresh man for C# programming, but i found that C# have no support for optional...
8
12908
by: deko | last post by:
I'm trying to open a Recordset based on a parameterized query. I'm kind of new to parameterized queries, so I'm sure I'm missing something simple. Set qdfs = db.QueryDefs Set qdf = qdfs("qryInvoices") qdf.Parameters("prmInv") = strInvoice qdf.Parameters("prmCid") = lngCustomerID Set rst = db.OpenRecordset("qryInvoices")
5
1839
by: Clownfish | last post by:
OK, I'm having a brain freeze. I have a table like this: Office Name Phone ---------------------------------- SG Larry 555-1212 SG Moe 553-4444 SG Curly 666-8888 PO Ren 222-9999
1
1740
Steve Kiss
by: Steve Kiss | last post by:
Hi. I am developping a site for which one of the pages uses querry strings to pass some parameters. I can use the querry strings if I call the page from a plain html anchor. However, when I add the URL to the sitemap I get the following error: The 'url' property had a malformed URL This is the offending URL:...
1
1487
by: nj2md | last post by:
Can some one assist with a querry. I need to know the code to querry a database to find the number of female and males that make over 50K a year and how to get capital gains and loses from the same database. Finally the code to count by occupation each country in the database. I Thanks in advance. I hope that this is enough data to assist...
0
1266
by: getmeidea | last post by:
I have the following tables, 1> employee_master(emp_id int primary key, emp_name varchar(100)); 2> employee_salary_payment(salary_rid int primary key, emp_id int, sal_date date, paid_amt int); The tables, employee_master and employee_salary_payment have one to many relation. I need to list the salary payment done for the employee having id...
0
7956
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7808
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6040
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5368
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5087
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3498
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1935
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1057
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
757
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.