Testing Connection To database

Add name space of system.data.oledb

This will test the connection of oracle database
private void button1_Click(object sender, EventArgs e)
        {
            oracon = new OleDbConnection("Provider=Msdaora;User Id=Scott;Password=tiger");
            oracon.Open();
            MessageBox.Show(oracon.State.ToString());
            oracon.Close();
            MessageBox.Show(oracon.State.ToString());
        }

this will test the connection of sql server database
        private void button2_Click(object sender, EventArgs e)
        {
            sqlcon = new OleDbConnection();
            sqlcon.ConnectionString = "Provider=SQLOLEDB;User Id=citrus_usr;Password=surtic;Database=DEMAT;Data Source=server";
            sqlcon.Open();
            MessageBox.Show(sqlcon.State.ToString());
            sqlcon.Close();
            MessageBox.Show(sqlcon.State.ToString());
        }
Ebook Download
View all
Learn
View all