Click here to Skip to main content
15,904,823 members
Home / Discussions / C#
   

C#

 
GeneralRe: My thoughts on C# Pin
Brian_TheLion4-Jun-19 14:16
Brian_TheLion4-Jun-19 14:16 
GeneralRe: My thoughts on C# Pin
Nathan Minier4-Jun-19 14:26
professionalNathan Minier4-Jun-19 14:26 
GeneralRe: My thoughts on C# Pin
Brian_TheLion4-Jun-19 14:30
Brian_TheLion4-Jun-19 14:30 
GeneralRe: My thoughts on C# Pin
Nathan Minier4-Jun-19 14:40
professionalNathan Minier4-Jun-19 14:40 
GeneralRe: My thoughts on C# Pin
Brian_TheLion4-Jun-19 14:53
Brian_TheLion4-Jun-19 14:53 
GeneralRe: My thoughts on C# Pin
Nathan Minier4-Jun-19 14:47
professionalNathan Minier4-Jun-19 14:47 
GeneralRe: My thoughts on C# Pin
Brian_TheLion4-Jun-19 15:12
Brian_TheLion4-Jun-19 15:12 
GeneralRe: My thoughts on C# Pin
Nathan Minier4-Jun-19 15:29
professionalNathan Minier4-Jun-19 15:29 
GeneralRe: My thoughts on C# Pin
Brian_TheLion4-Jun-19 16:37
Brian_TheLion4-Jun-19 16:37 
GeneralRe: My thoughts on C# Pin
Brian_TheLion4-Jun-19 15:28
Brian_TheLion4-Jun-19 15:28 
GeneralRe: My thoughts on C# Pin
Brian_TheLion4-Jun-19 15:38
Brian_TheLion4-Jun-19 15:38 
GeneralRe: My thoughts on C# Pin
Nathan Minier4-Jun-19 15:41
professionalNathan Minier4-Jun-19 15:41 
GeneralRe: My thoughts on C# Pin
Gerry Schmitz4-Jun-19 6:53
mveGerry Schmitz4-Jun-19 6:53 
GeneralRe: My thoughts on C# Pin
Brian_TheLion4-Jun-19 18:44
Brian_TheLion4-Jun-19 18:44 
QuestionHow to perform the content of a variable as a C# instruction Pin
Member 133074841-Jun-19 10:02
Member 133074841-Jun-19 10:02 
AnswerRe: How to perform the content of a variable as a C# instruction Pin
BillWoodruff1-Jun-19 15:33
professionalBillWoodruff1-Jun-19 15:33 
GeneralRe: How to perform the content of a variable as a C# instruction Pin
Member 133074841-Jun-19 18:22
Member 133074841-Jun-19 18:22 
AnswerRe: How to perform the content of a variable as a C# instruction Pin
jschell2-Jun-19 8:53
jschell2-Jun-19 8:53 
QuestionHow To Make This Generic Pin
Kevin Marois31-May-19 11:55
professionalKevin Marois31-May-19 11:55 
AnswerRe: How To Make This Generic Pin
#realJSOP1-Jun-19 5:00
professional#realJSOP1-Jun-19 5:00 
QuestionAsk C# everyone God, about SQLiteHelper increase delete to modify the static to directly call the way Pin
Dhjjf29-May-19 22:15
Dhjjf29-May-19 22:15 
AnswerRe: Ask C# everyone God, about SQLiteHelper increase delete to modify the static to directly call the way Pin
BillWoodruff29-May-19 22:41
professionalBillWoodruff29-May-19 22:41 
AnswerRe: Ask C# everyone God, about SQLiteHelper increase delete to modify the static to directly call the way Pin
Eddy Vluggen29-May-19 22:56
professionalEddy Vluggen29-May-19 22:56 
Before you read my complaints at the bottom, it is quite good code; rather readable, and already using parameterized queries. If this were in a project, I would not change it. I do have some suggestions of course.

Dhjjf wrote:
It can be called directly without using instantiation.
That's mostly limiting the existing class. Being able to create multiple connections and commands gives an added flexibility.

C#
private void TextBox2_TextChanged(object sender, EventArgs e)  //新增插入数据      
{    
  using (SQLiteConnection con = new SQLiteConnection(connectionString))
  using (SQLiteCommand cmd = con.CreateCommand())// this way u need not set con. property
  {
   try
   {
     cmd.CommandText = "INSERT INTO KD(postID,ddtime)values(@postID,@ddtime)";
            SQLiteParameter[] cmdParms = new SQLiteParameter[]{
             new SQLiteParameter("@postID", (textBox2.Text)),
             new SQLiteParameter("@ddtime", DateTime.Now)
                   };
      int recordsAffected = cmd.ExecuteNonQuery(cmdParms);
      Debug.Assert(recordsAffected != 1); //should only affect 1 record
   }
   catch (Exception ex)
   {
     Debug.WriteLine(ex.ToString()); // gives the complete message+stacktrace in debug window
     throw; // don't throw ex, just throw
   }
  }
} 
Also, your version would be harder to use than the OO-version; the original I can wrap in a decorator-pattern, extending its functionality without changing the original classes.
Bastard Programmer from Hell Suspicious | :suss:
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.

AnswerRe: Ask C# everyone God, about SQLiteHelper increase delete to modify the static to directly call the way Pin
OriginalGriff29-May-19 23:00
mveOriginalGriff29-May-19 23:00 
AnswerRe: Ask C# everyone God, about SQLiteHelper increase delete to modify the static to directly call the way Pin
#realJSOP30-May-19 4:55
professional#realJSOP30-May-19 4:55 

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.