return Sqlcon;
}
Catch
{
MessageBox.Show ("The database connection is unsuccessful!) please fill in the database settings correctly", "error", MessageBoxButtons.
}
Public DataView dvlist (string logstring,string tablename)//Returns a view of the corresponding table.
{
if (sqlconn. state = = connectionstate.closed)
Sqlconn. Open ();
SqlDataAdapter mycommand = new SqlDataAdapter (logstring, sqlconn);
DataSet ds = new DataSet ();
Try
{
Mycommand.fill (ds, "+tablename+");
}
Catch
{
MessageBox.Show ("error");
}
DataView Dv = new DataView ();
Dv = ds. tables["+tablename+"]. DefaultView;
return Dv;
}
public void Execute_sql (string sql,sqlconnection sqlconn)/Universal Execute SQL function
{
Open a database connection
if (sqlconn. state = = ConnectionState.Open)
Sqlconn. Close ();
Sqlconn. Open ();
SqlCommand cmd = new SqlCommand (sql, sqlconn);
Try
{
Cmd. ExecuteNonQuery ();
}
catch (SqlException AE)
{
MessageBox.Show (AE. Message.tostring ());
}
Cmd. Dispose ();
}
public void Show_listview_data (string select_str,string tablename,listview LV)/Universal return
tree view function
{
Lv=new ListView ();
Lv. Clear ();
This.sqldataadapter1=new SqlDataAdapter (Select_str,this.sqlconn);
SqlDataAdapter1.Fill (dataSet21, "+tablename+");
Add Column Name
for (int i=0;i<dataset21.tables["+tablename+"]. columns.count;i++)
{
Lv. Columns.Add (dataset21.tables["+tablename+"). Columns[i]. ColumnName.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service