Click here to Skip to main content
15,919,341 members
Home / Discussions / C#
   

C#

 
AnswerRe: i got some xml questions Pin
led mike5-May-09 4:31
led mike5-May-09 4:31 
QuestionConvert Variant in VB to C# Pin
klaydze5-May-09 3:22
klaydze5-May-09 3:22 
AnswerRe: Convert Variant in VB to C# Pin
Le centriste5-May-09 5:19
Le centriste5-May-09 5:19 
GeneralRe: Convert Variant in VB to C# Pin
klaydze6-May-09 2:20
klaydze6-May-09 2:20 
QuestionVariant in VB to C# Pin
klaydze5-May-09 3:13
klaydze5-May-09 3:13 
AnswerRe: Variant in VB to C# Pin
Simon P Stevens5-May-09 4:39
Simon P Stevens5-May-09 4:39 
GeneralRe: Variant in VB to C# Pin
klaydze6-May-09 2:17
klaydze6-May-09 2:17 
GeneralRe: Variant in VB to C# Pin
Simon P Stevens6-May-09 2:57
Simon P Stevens6-May-09 2:57 
klaydze wrote:
Any piece of advise?


It's unmaintainable and insecure code.

What if some nasty user comes along and calls
GetData("DROP DATABASE [yourdatabase]")
And this is just a minor problem. If you expose the ability to execute arbitrary SQL against your database you can wave goodbye to any serious form of security or data integrity.

If your just writing a prototype or for fun, don't worry about it too much. Just be aware the code is dangerous and should never grow into production code.

If this is production code I would advise a serious rethink about your architecture. You should create a separate data access layer. The DA layer should have strongly typed accessor methods, and they should being using pre written parametrized queries or stored procedures (Google those terms, it's pretty easy to use either with ADO.net)

E.g. you would have a UserDA class with a public User GetUser(String userName) method. The method would run the parametrized query and create a User object to be returned to the caller. This prevents a lot of issues. 1) You are only passing in the user name, not the whole SQL string so the caller can't execute whatever SQL they want. 2) You are returning a strongly typed User object so the caller gets exactly what they are expecting. 3) The use of stored procs or parametrized queries prevents SQL injection attacks. 4) You can build in security if you want and only allow certain users to retrieve and modify certain data.

Simon

GeneralRe: Variant in VB to C# Pin
klaydze6-May-09 3:51
klaydze6-May-09 3:51 
GeneralRe: Variant in VB to C# Pin
Simon P Stevens6-May-09 4:38
Simon P Stevens6-May-09 4:38 
GeneralRe: Variant in VB to C# Pin
klaydze6-May-09 4:58
klaydze6-May-09 4:58 
GeneralRe: Variant in VB to C# Pin
Simon P Stevens6-May-09 6:14
Simon P Stevens6-May-09 6:14 
GeneralRe: Variant in VB to C# Pin
klaydze7-May-09 3:44
klaydze7-May-09 3:44 
QuestionRich Text Box Flicker Pin
Paul Unsworth5-May-09 3:12
Paul Unsworth5-May-09 3:12 
AnswerRe: Rich Text Box Flicker Pin
Nuri Ismail5-May-09 5:45
Nuri Ismail5-May-09 5:45 
GeneralRe: Rich Text Box Flicker Pin
Paul Unsworth5-May-09 21:15
Paul Unsworth5-May-09 21:15 
QuestionCalling C# function in Java Pin
raesa5-May-09 1:40
raesa5-May-09 1:40 
AnswerRe: Calling C# function in Java Pin
Nagy Vilmos5-May-09 1:54
professionalNagy Vilmos5-May-09 1:54 
GeneralRe: Calling C# function in Java Pin
raesa5-May-09 2:02
raesa5-May-09 2:02 
GeneralRe: Calling C# function in Java Pin
Tom Deketelaere5-May-09 2:25
professionalTom Deketelaere5-May-09 2:25 
GeneralRe: Calling C# function in Java Pin
Nagy Vilmos5-May-09 2:29
professionalNagy Vilmos5-May-09 2:29 
QuestionProcess's changes Pin
lost_in_code5-May-09 1:09
lost_in_code5-May-09 1:09 
Questionc# socket server error Pin
Whydah5-May-09 0:49
Whydah5-May-09 0:49 
AnswerRe: c# socket server error Pin
stancrm5-May-09 2:09
stancrm5-May-09 2:09 
GeneralRe: c# socket server error Pin
Whydah5-May-09 3:20
Whydah5-May-09 3:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.