|
sure.
Change it to vb.
SqlConnection conn = null;
SqlDataAdapter dapt = null;
DataSet ds = new DataSet ();
string strConnectionString = "Data Source = .; initial catalog = database; uid = sa; pwd = xxx";
string strSQL = "SELECT field from table"
try
{
conn = new SqlConnection (strConnectionString);
conn.Open ();
dapt = new SqlDataAdapter (strSQL, conn);
dapt.Fill (ds, "table1");
DataTable dt = ds.Tabls [0];
if (dt.Rows.Count> 0)
{
this.Text1.Text = dt.Rows [0] ["field"]. ToString ();
}
Ranch
}
catch (System.Exception e)
{
this.Text1.Text = "Error" + e.Message;
}
finally
{
if (conn! = null)
conn.Dispose ();
if (dapt! = null)
dapt.Dispose ();
} |
|