Click here to Skip to main content
15,889,034 members
Home / Discussions / C#
   

C#

 
GeneralRe: Fundamental misunderstanding of structs as "value" types Pin
OriginalGriff28-Sep-18 4:55
mveOriginalGriff28-Sep-18 4:55 
Questionhow to create discussion forum in our asp.net application Pin
Member 1400092528-Sep-18 2:29
Member 1400092528-Sep-18 2:29 
AnswerRe: how to create discussion forum in our asp.net application Pin
Pete O'Hanlon28-Sep-18 3:24
mvePete O'Hanlon28-Sep-18 3:24 
Questionmake a design similar to windows mail in visual studio Pin
erdalczr28-Sep-18 0:46
erdalczr28-Sep-18 0:46 
AnswerRe: make a design similar to windows mail in visual studio Pin
OriginalGriff28-Sep-18 2:35
mveOriginalGriff28-Sep-18 2:35 
GeneralRe: make a design similar to windows mail in visual studio Pin
Richard MacCutchan28-Sep-18 3:29
mveRichard MacCutchan28-Sep-18 3:29 
GeneralRe: make a design similar to windows mail in visual studio Pin
OriginalGriff28-Sep-18 3:54
mveOriginalGriff28-Sep-18 3:54 
QuestionUploading a large Excel file using Entity Framework and Stored Procedure Call Pin
simpledeveloper27-Sep-18 8:40
simpledeveloper27-Sep-18 8:40 
AnswerRe: Uploading a large Excel file using Entity Framework and Stored Procedure Call Pin
Dave Kreskowiak27-Sep-18 9:50
mveDave Kreskowiak27-Sep-18 9:50 
GeneralRe: Uploading a large Excel file using Entity Framework and Stored Procedure Call Pin
simpledeveloper27-Sep-18 10:11
simpledeveloper27-Sep-18 10:11 
GeneralRe: Uploading a large Excel file using Entity Framework and Stored Procedure Call Pin
Member 140028821-Oct-18 0:10
Member 140028821-Oct-18 0:10 
GeneralRe: Uploading a large Excel file using Entity Framework and Stored Procedure Call Pin
Dave Kreskowiak1-Oct-18 4:20
mveDave Kreskowiak1-Oct-18 4:20 
GeneralRe: Uploading a large Excel file using Entity Framework and Stored Procedure Call Pin
Member 140028821-Oct-18 11:27
Member 140028821-Oct-18 11:27 
GeneralRe: Uploading a large Excel file using Entity Framework and Stored Procedure Call Pin
simpledeveloper1-Oct-18 13:30
simpledeveloper1-Oct-18 13:30 
GeneralRe: Uploading a large Excel file using Entity Framework and Stored Procedure Call Pin
Dave Kreskowiak1-Oct-18 15:52
mveDave Kreskowiak1-Oct-18 15:52 
GeneralRe: Uploading a large Excel file using Entity Framework and Stored Procedure Call Pin
simpledeveloper2-Oct-18 7:58
simpledeveloper2-Oct-18 7:58 
GeneralRe: Uploading a large Excel file using Entity Framework and Stored Procedure Call Pin
Dave Kreskowiak2-Oct-18 10:04
mveDave Kreskowiak2-Oct-18 10:04 
QuestionHow to allow null value inside datetime Pin
thepast27-Sep-18 2:54
thepast27-Sep-18 2:54 
AnswerRe: How to allow null value inside datetime Pin
OriginalGriff27-Sep-18 4:19
mveOriginalGriff27-Sep-18 4:19 
There are a couple of things here:
1) Text boxes don't contain NULL values - they can contain empty strings, but that is a very different thing.
2) ParseExact will fail if the string doesn't match - which means you must either use a try...catch block, or better use TryParseExact instead, reporting a problem to the user instead of trying to pass anything to the DB.
3) What you show won't work: even if it did what you think, it would pass the string version to SQL via concatenation, and that really should be avoided as it makes SQL convert the string back to a DateTime and that can introduce errors.

So verify the TB at the start of the method, and pass DateTime or NULL like this:
using (SqlConnection con = new SqlConnection(strConnect))
    {
    con.Open();
    using (SqlCommand cmd = new SqlCommand("INSERT INTO myTable (startDate) VALUES (@SD)", con))
        {
        object o;
        if (string.IsNullOrWhitespace(Startdate.text)) o = DbNull.Value;
        else o = valueConvertedToDateTimeEarilerWhenYouValidatedIt;
        cmd.Parameters.AddWithValue("@SD", o);
        cmd.ExecuteNonQuery();
        }
    }

Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!

QuestionHow to do server side pagination and searching in bootstrap table Pin
Member 1148667427-Sep-18 2:26
Member 1148667427-Sep-18 2:26 
AnswerRe: How to do server side pagination and searching in bootstrap table Pin
Richard Deeming28-Sep-18 1:11
mveRichard Deeming28-Sep-18 1:11 
Questionstudent's concern Pin
Member 1399919126-Sep-18 20:44
Member 1399919126-Sep-18 20:44 
AnswerRe: student's concern Pin
OriginalGriff26-Sep-18 21:01
mveOriginalGriff26-Sep-18 21:01 
AnswerRe: student's concern Pin
Richard MacCutchan26-Sep-18 21:16
mveRichard MacCutchan26-Sep-18 21:16 
PraiseRe: student's concern Pin
Maciej Los26-Sep-18 21:44
mveMaciej Los26-Sep-18 21:44 

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.