Click here to Skip to main content
15,887,175 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Application design for multiple databases Pin
Stephen Holdorf16-May-16 2:33
Stephen Holdorf16-May-16 2:33 
QuestionHow to use Datarelation to Create Menu in c# asp.net Pin
Ameer Dhotre12-May-16 21:02
Ameer Dhotre12-May-16 21:02 
QuestionRe: How to use Datarelation to Create Menu in c# asp.net Pin
ZurdoDev16-May-16 3:08
professionalZurdoDev16-May-16 3:08 
AnswerRe: How to use Datarelation to Create Menu in c# asp.net Pin
Ameer Dhotre23-May-16 1:41
Ameer Dhotre23-May-16 1:41 
GeneralRe: How to use Datarelation to Create Menu in c# asp.net Pin
ZurdoDev23-May-16 1:46
professionalZurdoDev23-May-16 1:46 
GeneralRe: How to use Datarelation to Create Menu in c# asp.net Pin
Ameer Dhotre26-May-16 0:48
Ameer Dhotre26-May-16 0:48 
QuestionQuery About getting difference between two dates in mvc4 Pin
Member 1251934112-May-16 2:52
Member 1251934112-May-16 2:52 
SuggestionRe: Query About getting difference between two dates in mvc4 Pin
Richard Deeming12-May-16 3:20
mveRichard Deeming12-May-16 3:20 
Your code is vulnerable to SQL Injection[^]. NEVER use string concatenation to build a SQL query. ALWAYS use a parameterized query.

Everything you wanted to know about SQL injection (but were afraid to ask) | Troy Hunt[^]
How can I explain SQL injection without technical jargon? | Information Security Stack Exchange[^]
Query Parameterization Cheat Sheet | OWASP[^]


Also, you should never connect to your database as sa; that's an administrator account which could be used to totally destroy your server, or even your network. Your application should connect as a specific user which has only the permissions required by your application.

And if that's your real sa password that you've just posted to a public forum, you should change it immediately. And this time, pick something secure!


Rather than hard-coding your connection string every time you open a connection, store it in the <connectionStrings> section of your web.config file. That way, when you need to change it, you only have to do it in one place.

Your SqlConnection and SqlCommand objects should be wrapped in using blocks to ensure that their resources are always cleaned up:
C#
using (SqlConnection conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["connectionString"].ConnectionString))
{
    ...
}

It's generally considered a good idea to move data-access code out of your controller and into a separate "repository" class. That makes it much easier to test the data-access code without having to hit the controller, and to test your controller without touching the database.



"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer


AnswerRe: Query About getting difference between two dates in mvc4 Pin
John C Rayan13-May-16 1:22
professionalJohn C Rayan13-May-16 1:22 
QuestionVisual Studio Community 2015 and Metro-UI-CSS Pin
xiecsuk10-May-16 3:26
xiecsuk10-May-16 3:26 
AnswerRe: Visual Studio Community 2015 and Metro-UI-CSS Pin
Richard Deeming10-May-16 6:34
mveRichard Deeming10-May-16 6:34 
GeneralRe: Visual Studio Community 2015 and Metro-UI-CSS Pin
xiecsuk10-May-16 6:46
xiecsuk10-May-16 6:46 
Questionhi experts..i'm using dropdownlist statically for gender field its not show me proper data when im update Pin
sunil39-May-16 19:25
sunil39-May-16 19:25 
AnswerRe: hi experts..i'm using dropdownlist statically for gender field its not show me proper data when im update Pin
ZurdoDev10-May-16 3:37
professionalZurdoDev10-May-16 3:37 
AnswerRe: hi experts..i'm using dropdownlist statically for gender field its not show me proper data when im update Pin
John C Rayan12-May-16 1:56
professionalJohn C Rayan12-May-16 1:56 
GeneralRe: hi experts..i'm using dropdownlist statically for gender field its not show me proper data when im update Pin
sunil317-May-16 20:19
sunil317-May-16 20:19 
GeneralRe: hi experts..i'm using dropdownlist statically for gender field its not show me proper data when im update Pin
John C Rayan18-May-16 1:12
professionalJohn C Rayan18-May-16 1:12 
QuestionCalendar Pin
Member 125105918-May-16 15:09
Member 125105918-May-16 15:09 
AnswerRe: Calendar Pin
John C Rayan12-May-16 1:59
professionalJohn C Rayan12-May-16 1:59 
QuestionHow to block bad users Pin
Vimalsoft(Pty) Ltd7-May-16 23:37
professionalVimalsoft(Pty) Ltd7-May-16 23:37 
GeneralRe: How to block bad users Pin
Kornfeld Eliyahu Peter8-May-16 1:43
professionalKornfeld Eliyahu Peter8-May-16 1:43 
AnswerRe: How to block bad users Pin
John C Rayan12-May-16 2:09
professionalJohn C Rayan12-May-16 2:09 
QuestionPassing a std::list using gSOAP Pin
GazMiller19794-May-16 21:39
GazMiller19794-May-16 21:39 
Questionhi experts imgetting the error index out of rang pls help to solve Pin
sunil34-May-16 21:04
sunil34-May-16 21:04 
AnswerRe: hi experts imgetting the error index out of rang pls help to solve Pin
Richard MacCutchan4-May-16 22:58
mveRichard MacCutchan4-May-16 22:58 

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.