2011-09-05 9 views
7

रीडर हमेशा null है, मुझे नहीं पता कि क्यों।कमांडटेक्स्ट प्रॉपर्टी को ठीक से शुरू नहीं किया गया है (MySqlDataReader)

कनेक्शन एक विधि में था, सबकुछ ठीक काम करता था।

कोड:

private MySqlConnection connection; 
private MySqlCommand command; 
private MySqlDataReader Reader; 

public Form1() 
{ 
    InitializeComponent(); 
    DBint(); 
} 
private void DBint() 
{ 
    string myConnectionString = "SERVER=xxx;PORT=3306;" + 
           "DATABASE=xxx;" + 
           "UID=root;" + 
           "PASSWORD=xxx;"; 
    connection = new MySqlConnection(myConnectionString); 
    command = connection.CreateCommand(); 
    MySqlDataReader Reader;//error occures her 
    connection.Open(); 
    Reader = command.ExecuteReader();    
    //MessageBox.Show(tmp);     
    //connection.Close();  
} 

उत्तर

10

आप अपने SELECT बयान या संग्रहीत प्रक्रिया नाम के साथ आदेश वस्तु की CommandText संपत्ति स्थापित करना चाहिए, आप एक खाली आदेश पर अमल नहीं कर सकते।

संबंधित मुद्दे