using System.Data;
using System.Data.SqlClient;
. . . . .
private void Form1_Load(object sender, EventArgs e)
{
// Initialize DataSet and give it a name
this.dataSet = new DataSet("dataSet");
// Initialize the SqlConnection providing the connection string
this.sqlConnection1 = new SqlConnection("Data Source=(local);Initial Catalog=Northwind;Integrated Security=True");
// Initialize the SqlCommand that contains the Select command
this.sqlCommand1 = new SqlCommand("SELECT CategoryName, Picture FROM Categories");
// Assign the SqlConnection to the Connection property of the SqlCommand.
this.sqlCommand1.Connection = this.sqlConnection1;
// Initialize the SqlDataAdapter
this.sqlAdapter1 = new SqlDataAdapter();
// Assign the SelectCommand property of Adapter to the SqlCommand that has been created(SQL Query).
this.sqlAdapter1.SelectCommand = sqlCommand1;
try
{
// Fill the DataSet
this.sqlAdapter1.Fill(this.dataSet);
// Assign the DataSet's DefaultView to a control's data source.
this.ultraCarousel1.DataSource = this.dataSet.Tables[0].DefaultView;
}
catch (SqlException ex)
{
// Catch and display any exceptions that may occur
MessageBox.Show(ex.Message.ToString());
}
}