Click here to Skip to main content
15,171,729 members
Home / Discussions / Android
   

Android

 
GeneralRe: Method not returning expected value Pin
Davidw196924-Feb-17 17:41
MemberDavidw196924-Feb-17 17:41 
AnswerRe: Method not returning expected value Pin
Jochen Arndt23-Feb-17 4:45
professionalJochen Arndt23-Feb-17 4:45 
GeneralRe: Method not returning expected value Pin
Richard MacCutchan23-Feb-17 6:45
mveRichard MacCutchan23-Feb-17 6:45 
AnswerRe: Method not returning expected value Pin
Davidw196924-Feb-17 17:52
MemberDavidw196924-Feb-17 17:52 
AnswerRe: Method not returning expected value Pin
Richard MacCutchan23-Feb-17 4:58
mveRichard MacCutchan23-Feb-17 4:58 
GeneralRe: Method not returning expected value Pin
Davidw196924-Feb-17 17:53
MemberDavidw196924-Feb-17 17:53 
QuestionAndroid and C# Web Services Pin
Member 1155786814-Feb-17 23:41
MemberMember 1155786814-Feb-17 23:41 
SuggestionRe: Android and C# Web Services Pin
Richard Deeming15-Feb-17 3:39
mveRichard Deeming15-Feb-17 3:39 
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[^]

C#
try
{
    using (var con = new SqlConnection(ConfigurationManager.ConnectionStrings["dbconnection"].ConnectionString))
    using (var cmd = new SqlCommand("INSERT INTO GPSTrackerCar (data, car, lat, lng) VALUES (GetDate(), @car, @lat, @lng)", con))
    {
        cmd.Parameters.AddWithValue("@car", car);
        cmd.Parameters.AddWithValue("@lat", lat);
        cmd.Parameters.AddWithValue("@lng", lng);
        
        con.Open();
        cmd.ExecuteNonQuery();
        return "OK";
    }
}
catch(SqlException ex)
{
    return ex.Message;
}


Also, if your lat and lng parameters represent latitude and longitude, you should use a more specific data type - for example, double.

And a method name starting with Get suggests that it's going to retrieve data, but your method is inserting data. I'd suggest changing the name to something like StoreCoordinates.



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


QuestionAndroid: High Pass filter Pin
Himanshu Bhutani13-Feb-17 2:36
MemberHimanshu Bhutani13-Feb-17 2:36 
QuestionRe: Android: High Pass filter Pin
David Crow13-Feb-17 3:41
MemberDavid Crow13-Feb-17 3:41 
AnswerRe: Android: High Pass filter Pin
Nick_314159265415-Apr-17 4:55
MemberNick_314159265415-Apr-17 4:55 
QuestionAndroid Day of Week Calculator Pin
Pavlex49-Feb-17 10:50
MemberPavlex49-Feb-17 10:50 
AnswerRe: Android Day of Week Calculator Pin
David Crow9-Feb-17 11:02
MemberDavid Crow9-Feb-17 11:02 
GeneralRe: Android Day of Week Calculator Pin
Pavlex49-Feb-17 11:09
MemberPavlex49-Feb-17 11:09 
GeneralRe: Android Day of Week Calculator Pin
David Crow9-Feb-17 11:12
MemberDavid Crow9-Feb-17 11:12 
GeneralRe: Android Day of Week Calculator Pin
Pavlex49-Feb-17 11:15
MemberPavlex49-Feb-17 11:15 
SuggestionRe: Android Day of Week Calculator Pin
David Crow9-Feb-17 11:23
MemberDavid Crow9-Feb-17 11:23 
GeneralRe: Android Day of Week Calculator Pin
Pavlex49-Feb-17 11:32
MemberPavlex49-Feb-17 11:32 
GeneralRe: Android Day of Week Calculator Pin
David Crow9-Feb-17 11:36
MemberDavid Crow9-Feb-17 11:36 
GeneralRe: Android Day of Week Calculator Pin
Pavlex49-Feb-17 11:38
MemberPavlex49-Feb-17 11:38 
GeneralRe: Android Day of Week Calculator Pin
Richard MacCutchan9-Feb-17 22:07
mveRichard MacCutchan9-Feb-17 22:07 
GeneralRe: Android Day of Week Calculator Pin
Pavlex49-Feb-17 22:39
MemberPavlex49-Feb-17 22:39 
GeneralRe: Android Day of Week Calculator Pin
Richard MacCutchan9-Feb-17 23:20
mveRichard MacCutchan9-Feb-17 23:20 
GeneralRe: Android Day of Week Calculator Pin
David Crow10-Feb-17 3:08
MemberDavid Crow10-Feb-17 3:08 
GeneralRe: Android Day of Week Calculator Pin
Richard MacCutchan10-Feb-17 3:46
mveRichard MacCutchan10-Feb-17 3:46 

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.