Click here to Skip to main content
15,886,110 members
Home / Discussions / C#
   

C#

 
GeneralRe: Class Diagram relation issue Pin
Pete O'Hanlon19-Apr-07 2:06
mvePete O'Hanlon19-Apr-07 2:06 
AnswerRe: Class Diagram relation issue Pin
Saira Tanwir19-Apr-07 2:36
Saira Tanwir19-Apr-07 2:36 
QuestionDataGrid Pin
nuraprakash18-Apr-07 21:24
nuraprakash18-Apr-07 21:24 
AnswerRe: DataGrid Pin
baerten18-Apr-07 21:33
baerten18-Apr-07 21:33 
Questioncopying row in datagridview Pin
phantanagu18-Apr-07 21:10
phantanagu18-Apr-07 21:10 
AnswerRe: copying row in datagridview Pin
Sathesh Sakthivel18-Apr-07 21:19
Sathesh Sakthivel18-Apr-07 21:19 
AnswerRe: copying row in datagridview [modified] Pin
phantanagu18-Apr-07 22:08
phantanagu18-Apr-07 22:08 
QuestionSQLCommand parameters to prevent SQL injections Pin
GermanDM18-Apr-07 21:07
GermanDM18-Apr-07 21:07 
Hi,

Would this be a good way to prevent some SQL Injections?
I am trying to find the best easiest way to use of command parameters whenever i receive user input to query a database.
I have alot of queries so im trying to find a easy reusable procedures to make use of sqlcommand parameters.

<br />
SqlConnection conn = new SqlConnection(_WebConfig.ConnectionString.ToString());<br />
        try<br />
        {<br />
            <br />
            DataTable dtVal = new DataTable();<br />
            SqlDataAdapter da = new SqlDataAdapter("SELECT ID, Full_Name, Surname " +<br />
                                                                "FROM Users " +<br />
                                                                "WHERE Full_Name = @LoginUname " +<br />
                                                                  "AND Password = @LoginPword", conn);<br />
            da.SelectCommand.Parameters.Add("@LoginUname", SqlDbType.VarChar, 30);<br />
            da.SelectCommand.Parameters["@LoginUname"].Value = LoginUname;<br />
<br />
            da.SelectCommand.Parameters.Add("@LoginPword", SqlDbType.VarChar, 15);<br />
            da.SelectCommand.Parameters["@LoginPword"].Value = LoginPword;<br />
        <br />
            if (conn.State == ConnectionState.Closed | conn.State == ConnectionState.Closed)<br />
            {<br />
                conn.Open();<br />
            }<br />
            da.Fill(dtVal);<br />
<br />
            if (dtVal.Rows.Count == 1)<br />
            {<br />
                return true;<br />
            }<br />
            else<br />
            {<br />
                return false;<br />
            }<br />
        }<br />
        catch (Exception ex)<br />
        {<br />
            throw ex;<br />
        }<br />
        finally<br />
        {<br />
            conn.Close();<br />
            conn.Dispose();<br />
        }                  <br />


Any advice or other methods would be greatly appreciated
Thanks
AnswerRe: SQLCommand parameters to prevent SQL injections Pin
Stefan Troschuetz18-Apr-07 21:11
Stefan Troschuetz18-Apr-07 21:11 
AnswerRe: DataGridView validation Pin
Sathesh Sakthivel18-Apr-07 21:14
Sathesh Sakthivel18-Apr-07 21:14 
GeneralRe: DataGridView validation Pin
7118-Apr-07 21:36
7118-Apr-07 21:36 
QuestionWeb Service Authentication Pin
Cheng Dehua18-Apr-07 20:42
Cheng Dehua18-Apr-07 20:42 
AnswerRe: Web Service Authentication Pin
Sathesh Sakthivel18-Apr-07 20:54
Sathesh Sakthivel18-Apr-07 20:54 
QuestionMaking a listView sub item clickable Pin
AngryC18-Apr-07 20:24
AngryC18-Apr-07 20:24 
AnswerRe: Making a listView sub item clickable Pin
Patrick Etc.19-Apr-07 4:42
Patrick Etc.19-Apr-07 4:42 
QuestionHow to add click event to a personalized ContextMenu? Pin
Khoramdin18-Apr-07 20:21
Khoramdin18-Apr-07 20:21 
AnswerRe: How to add click event to a personalized ContextMenu? Pin
Luc Pattyn19-Apr-07 0:05
sitebuilderLuc Pattyn19-Apr-07 0:05 
QuestionHow to deploye c# Application Pin
suveenmohan18-Apr-07 20:20
suveenmohan18-Apr-07 20:20 
AnswerRe: How to deploye c# Application Pin
Sathesh Sakthivel18-Apr-07 20:51
Sathesh Sakthivel18-Apr-07 20:51 
QuestionDrawing in picture box--C#/opengl help Pin
Raza568018-Apr-07 19:32
Raza568018-Apr-07 19:32 
AnswerRe: Drawing in picture box--C#/opengl help Pin
Christian Graus18-Apr-07 20:00
protectorChristian Graus18-Apr-07 20:00 
QuestionRead Word documents using stringreader? Pin
K.Ravich18-Apr-07 19:24
K.Ravich18-Apr-07 19:24 
AnswerRe: Read Word documents using stringreader? Pin
Sathesh Sakthivel18-Apr-07 19:45
Sathesh Sakthivel18-Apr-07 19:45 
QuestionForm closing or disposing Pin
EEmaan18-Apr-07 18:58
EEmaan18-Apr-07 18:58 
AnswerRe: Form closing or disposing Pin
Jaiprakash M Bankolli18-Apr-07 19:54
Jaiprakash M Bankolli18-Apr-07 19:54 

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.