12-09-2011، 11:10 PM
این قطعه برنامه چه مشکلی داره؟ قبل از اجرا هیچ اروری نمی ده ولی زمان اجرا در خط dv.sort["soal"] ایراد می گیره
namespace kalanjar
{
public partial class Form1 : Form
{
SqlConnection conn = new SqlConnection("Server=DANESH-PC\\SQLEXPRESS ;Database = kalanjar; trusted_connection=yes");
SqlCommand cmd = new SqlCommand();
DataTable dt = new DataTable();
DataSet ds= new DataSet ();
DataView dv = new DataView();
SqlDataAdapter da;
int tempp;
public Form1()
{
InitializeComponent();
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
dv.Sort = "soal";
tempp= dv.Find(textBox1.Text.Trim());
if (tempp != -1)
{
textBox2.Text = dv[tempp]["javab"].ToString() ;
}
}
private void Form1_Load(object sender, EventArgs e)
{
conn.Open();
da = new SqlDataAdapter("select * from table1", conn);
cmd.Connection = conn;
da.Fill(ds);
dv.Table = ds.Tables["table1"];
}
}
}
namespace kalanjar
{
public partial class Form1 : Form
{
SqlConnection conn = new SqlConnection("Server=DANESH-PC\\SQLEXPRESS ;Database = kalanjar; trusted_connection=yes");
SqlCommand cmd = new SqlCommand();
DataTable dt = new DataTable();
DataSet ds= new DataSet ();
DataView dv = new DataView();
SqlDataAdapter da;
int tempp;
public Form1()
{
InitializeComponent();
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
dv.Sort = "soal";
tempp= dv.Find(textBox1.Text.Trim());
if (tempp != -1)
{
textBox2.Text = dv[tempp]["javab"].ToString() ;
}
}
private void Form1_Load(object sender, EventArgs e)
{
conn.Open();
da = new SqlDataAdapter("select * from table1", conn);
cmd.Connection = conn;
da.Fill(ds);
dv.Table = ds.Tables["table1"];
}
}
}