using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace test
{
public partial class Form16json : Form
{
public Form16json()
{
InitializeComponent();
}
SqlConnection conn;
static SqlCommand comm;
SqlDataReader sdr;
private void Form16json_Load(object sender, EventArgs e)
{
//findInfo("展览馆");
MessageBox.Show(findInfo("展览馆")[1].CaseAddress.ToString());
}
public List<info> findInfo(string txtFind)
{
List<info> list = new List<info>();
try
{
conn = new SqlConnection("server=.;uid=sa;pwd=123;database=BJG_CaseExchangeDB");
conn.Open();
string strSQL = "select * from CaseInfo where CaseAddress like '%" + txtFind + "%'";
comm = new SqlCommand(strSQL, conn);
sdr = comm.ExecuteReader();
info strInfo = new info();
while (sdr.Read())
{
strInfo = new info { CaseType = sdr[1].ToString(), CaseBigClass = sdr[2].ToString(), CaseSmallClass = sdr[3].ToString(), CaseAddress = sdr[4].ToString(), CoordX = sdr[5].ToString(), CoordY = sdr[6].ToString(), SubmitTime = sdr[7].ToString() };
list.Add(strInfo);
}
if (!sdr.HasRows)
{
strInfo = new info { CaseType = "无匹配记录" };
list.Add(strInfo);
}
sdr.Close();
}
catch (Exception e)
{
}
return list;
}
public class info
{
public string CaseType { get; set; }
public string CaseBigClass { get; set; }
public string CaseSmallClass { get; set; }
public string CaseAddress { get; set; }
public string CoordX { get; set; }
public string CoordY { get; set; }
public string SubmitTime { get; set; }
}
}
}