المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : C# DataAdapter.Fill is ending load code?



C# Programming
10-07-2009, 03:40 PM
gday all,

im having a problem with a C# application im developing.

the code is as follows.

...



namespace Keystore

{

public partial class FindKey : Form

{

public FindKey()

{

InitializeComponent();

}



DataSet ds;

System.Data.SqlClient.SqlDataAdapter da;

DatabaseHelper dataHelper = new DatabaseHelper();

DataRow dRow;



private void FindKey_Load(object sender, EventArgs e)

{

string sql = "SELECT * FROM Key";

string name = "AllKeys";

da = dataHelper.getAdapter(sql, name);

ds = dataHelper.getDataSet();



*******List(1);

fillcboProvider();

fillcboProduct();



}



...



...



namespace Keystore

{



class DatabaseHelper

{

System.Data.SqlClient.SqlConnection con;

DataSet ds;

System.Data.SqlClient.SqlDataAdapter da;



public DatabaseHelper()

{

con = new System.Data.SqlClient.SqlConnection();

con.ConnectionString = "Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|\\KeyStore.mdf;Integrated Security=True;User Instance=True";

ds = new DataSet();

}



public System.Data.SqlClient.SqlDataAdapter getAdapter(String sql, String name)

{

da = new System.Data.SqlClient.SqlDataAdapter(sql, con);

da.Fill(ds, name); *** Code 'finishes' the load after here ***

return da;

}



...

The code seems to be ending the "load" phase at the marked line (marked with ***)

theres no error message, the program doesn't hang or anything... It just seems to be stopping the load there and displaying my form without any data in it.

Has anyone had this problem before? Can anyone help me fix it?

Also, can anyone tell me if the MSDN forums are down? i can't get to them for some reason...

Cheers in advance!