SqlDataSource、SqlConnection
SqlDataSource sds01 = new SqlDataSource();
sds01.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["CylinderConnectionString"].ToString();
sds01.SelectCommand = "SELECT * FROM [tableName]";
System.Data.DataView dv = (System.Data.DataView)sds01.Select(DataSourceSelectArguments.Empty);
if (dv.Table.Rows.Count != 1) return;
string id = (string)dv.Table.Rows[0]["id"];
string num = (string)dv.Table.Rows[0][0];
sds01.Dispose();
SqlConnection cn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["CylinderConnectionString"].ToString());
cn.Open();
string l_sql = string.Format("select [cylSize] from [cylInfo] where [cylNo]='{0}'", cylno);
SqlCommand cmd = new SqlCommand(l_sql, cn);
string cylSize = cmd.ExecuteScalar().ToString();
cn.Close();
cn.Dispose();
SqlConnection cn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["CylinderConnectionString"].ToString());
cn.Open();
string l_sql = "select [cylSize] from [cylInfo] where [cylno]=@cylNum";
SqlCommand cmd = new SqlCommand(l_sql, cn);
cmd.Parameters.Add("@cylNum", SqlDbType.NVarChar).Value = cylno;
string cylSize = cmd.ExecuteScalar().ToString();
cn.Close();
cn.Dispose();
SqlConnection cn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["CylinderConnectionString"].ToString());
cn.Open();
string l_sql = "select cylSize from [cylInfo] where [cylNum]=@cylNum";
SqlCommand cmd = new SqlCommand(l_sql, cn);
cmd.Parameters.Add("@cylNum", SqlDbType.NVarChar).Value = cylno;
SqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
string cylSize = reader["cylSize"].ToString();
}
cn.Close();
cn.Dispose();
SqlDataSource sds03 = new SqlDataSource();
sds03.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["TGEEF"].ToString();
sds03.SelectParameters.Add("aqc001002", aqc001002);
sds03.SelectCommand = "SELECT * FROM [aqc001_cyl_info] WHERE ([aqc001002] = @aqc001002)";
System.Data.DataView dv3 = (System.Data.DataView)sds03.Select(DataSourceSelectArguments.Empty);
if (dv3.Table.Rows.Count == 0) return;
sds03.Dispose();
foreach( System.Data.DataRow l_row in dv3.Table.Rows)
{
string aa = l_row["aqc001002"].ToString();
}