Quantcast
Channel: Visual C# forum
Viewing all articles
Browse latest Browse all 31927

Code stops executing at DataAdapter.Fill line??

$
0
0
hey guys, cant work out why the following code is stopping on the marked line (marked with ***)

...namespace Keystore

{

publicpartialclass FindKey : Form

{

public FindKey()

{

InitializeComponent();

}



DataSet ds;

System.Data.SqlClient.SqlDataAdapter da;

DatabaseHelper dataHelper = new DatabaseHelper();

DataRow dRow;



privatevoid FindKey_Load(object sender, EventArgs e)

{

string sql = "SELECT * FROM Key";string name = "AllKeys";

da = dataHelper.getAdapter(sql, name);

ds = dataHelper.getDataSet();



refreshList(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 stops executing after here ***

return da;

}



... <br />

If anyone has encountered this before, or knows why its happening, or a way around it, let me know plz!

Thanks in advance!

Viewing all articles
Browse latest Browse all 31927

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>