简体   繁体   中英

error while connecting to the SQL database

This is what I get:

'PatientDatabase.Properties.Settings' does not contain a definition for 'SQL' and no extension method 'SQL' accepting a first argument of type 'PatientDatabase.Properties.Settings' could be found (are you missing a using directive or an assembly reference?)`

Here is my code:

private void Form1_Load(object sender, EventArgs e)
{
        try
        {
            objConnect = new DatabaseConnection();
            conString = Properties.Settings.Default.patientDetailsConnectionString;

            objConnect.connection_string = conString;

            objConnect.sql = Properties.Settings.Default.SQL;

            ds = objConnect.GetConnection;

            MaxRows = ds.Tables[0].Rows.Count;
            NavigateRecords();

        }
        catch (Exception err)
        {
            MessageBox.Show(err.Message);
        }
}

It means that you don't have SQL in your settings file. Make sure that it exists and the casing is correct. Open the settings file and add node with SQL there. You can read the details here of how you can do that.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM