can someone tell me what I did wrong?
my code below. gives me error message says:
an error has occurred while establishing connection server. when connecting sql server 2005, failure may caused fact under default settings sql server not allow remote connections. (provider: sql network interfaces, error: 26 - error locating server/instance specified)
my code is:
sqlconnection testconnection = new sqlconnection();
sqldataadapter testadapter = new sqldataadapter();
datatable testtable = new datatable();
int rowposition = 0;
private void mainform_load(object sender, eventargs e)
{
this.marketstatus();
testconnection.connectionstring = @"data source=i:\documents\visual studio 2005\projects\stockproject\stockproject\stocks.sdf;integrated security=sspi";
testconnection.open();
testadapter = new sqldataadapter("select * stockinfo", testconnection);
sqlcommandbuilder testcommandbuilder = new sqlcommandbuilder(testadapter);
testadapter.fill(testtable);
this.databasetest();
}
private void databasetest()
{
if (testtable.rows.count == 0)
{
txtstocksymboltest.text = "";
txtlasttrade.text = "";
return;
}
else
{
txtstocksymboltest.text = testtable.rows[rowposition]["stocksymbol"].tostring();
txtlasttrade.text = testtable.rows[rowposition]["lasttrade"].tostring();
}
}
private void mainform_formclosed(object sender, formclosedeventargs e)
{
testconnection.close();
this.close();
}
an error has occurred while establishing connection server. when connecting sql server 2005, failure may caused fact under default settings sql server not allow remote connections. (provider: sql network interfaces, error: 26 - error locating server/instance specified)
my code is:
sqlconnection testconnection = new sqlconnection();
sqldataadapter testadapter = new sqldataadapter();
datatable testtable = new datatable();
int rowposition = 0;
private void mainform_load(object sender, eventargs e)
{
this.marketstatus();
testconnection.connectionstring = @"data source=i:\documents\visual studio 2005\projects\stockproject\stockproject\stocks.sdf;integrated security=sspi";
testconnection.open();
testadapter = new sqldataadapter("select * stockinfo", testconnection);
sqlcommandbuilder testcommandbuilder = new sqlcommandbuilder(testadapter);
testadapter.fill(testtable);
this.databasetest();
}
private void databasetest()
{
if (testtable.rows.count == 0)
{
txtstocksymboltest.text = "";
txtlasttrade.text = "";
return;
}
else
{
txtstocksymboltest.text = testtable.rows[rowposition]["stocksymbol"].tostring();
txtlasttrade.text = testtable.rows[rowposition]["lasttrade"].tostring();
}
}
private void mainform_formclosed(object sender, formclosedeventargs e)
{
testconnection.close();
this.close();
}
the same issue discussed here
http://forums.microsoft.com/msdn/showpost.aspx?postid=591597&siteid=1
http://forums.microsoft.com/msdn/showpost.aspx?postid=1645863&siteid=1
madhu
SQL Server > SQL Server Data Access
Comments
Post a Comment