Home > Net >  Ask class members assignment problem
Ask class members assignment problem

Time:05-20

 public SQLiteCommand SQLiteCommand; 
Public SQLiteConnection SQLiteConnection;

Definition of the two variables, in the first time to use normal initialization and assignment, use normal,
 
SQLiteCommand=new SQLiteCommand ();
SQLiteCommand. Connection=SQLiteConnection;
SQLiteCommand.Com mandText=SQLstring;

SQLiteDataReader Dr=SQLiteCommand. ExecuteReader ();

ListView2. BeginUpdate ();
ListView2. The Clear ();

While (Dr. Read ())
{
ColumnHeader Col=new ColumnHeader ();
Col. Text=Dr [r]. "the Name" the ToString ();
Col. TextAlign=HorizontalAlignment. Center;
ListView2. Columns. The Add (Col);
}

The second assignment when they go wrong, the teacher please help to give directions, thank you!
 
SQLstring=the string. Format (" SELECT * FROM {0} "and listBox1. SelectedItem. The ToString ());
SQLiteCommand.Com mandText=SQLstring;////the error
//SQLiteCommand=new SQLiteCommand ();////if the re-initialization can be normal, but should be able to assign a value of
SQLiteCommand. Connection=SQLiteConnection;
Dr=SQLiteCommand. ExecuteReader ();
  •  Tags:  
  • C#
  • Related