110,538
社区成员
发帖
与我相关
我的任务
分享
SqlCommand Comd = new SqlCommand(sqlstr, sqlConn);
SqlDataAdapter Da = new SqlDataAdapter();
Da.SelectCommand = Comd;
Comd.CommandType = CommandType.Text;
DataSet Ds = new DataSet("Attractions");
Da.Fill(Ds, "Attractions");
DataTable table = new DataTable();
table = Ds.Tables["Attractions"];
string conn = "Trusted_Connection=SSPI";
SqlConnection sqlConn = new SqlConnection(conn );
sqlConn.Open();
string a = String.Empty;
string sqlstr = String.Empty;
string txtNS = txtInputName.Text;
string combNS = String.Empty;
combNS = comboBoxSelectKind.SelectedItem.ToString();
if (txtNS.Length == 0 || combNS.Length == 0 )
{
MessageBox.Show("请输入景点名称");
}
string NF = String.Empty;
string[,] s = new string[,] { { "地质", "tp_Geology" }, { "土壤", "tp_Soil" }, { "植物", "tp_Plant" }, { "气候", "tp_Climate" }, { "地貌", "tp_Relief" } };
for (int i = 0; i < 5; i++)
{
if (combNS == s[i, 0])
{
NF = s[i, 0];
a = s[i, 1];
}
}
sqlstr = "select Kind ,NF from Attractions where Kind = txtNS and a = combNS";
try
{
SqlCommand Comd = new SqlCommand(sqlstr, sqlConn);
SqlDataAdapter Da = new SqlDataAdapter();
Da.SelectCommand = Comd;
Comd.CommandType = CommandType.Text;
DataSet Ds = new DataSet("Attractions");
DataTable table = new DataTable();
table = Ds.Tables.Add ("Attractions");
Da.Fill(Ds, "Attractions");
DataRow row = table.NewRow();
string bh = Ds.Tables["Attractions"].Rows[Convert.ToInt32(txtNS)][a].ToString();
lblShow.Text = bh;
sqlConn.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
DataSet Ds = new DataSet();
DataTable table = new DataTable();
table = Ds.Tables.Add ("Attractions");
Da.Fill(Ds, "Attractions");
string conn = "Initial Catalog = lushan;Data Source = CHY;" + "Integrated Security = SSPI";
SqlConnection sqlConn = new SqlConnection(conn );
sqlConn.Open();