A
ashkaan57
Hi all,
I am new to ASP.NET and VS 2005 Express.
I am having problems with an error message and can't figure out why.
I am trying to run a "SELECT" query triggered by a change in dropdown .
When I hit the line:
DataView dv =
(DataView)(SiteInfoDS.Select(DataSourceSelectArguments.Empty));
in the code below, I get:
"Format of initializaion string does not conform to specification
starting at index 0".
I changed it so DataSourceSelectArguments args = new
DataSourceSelectArguments();
and used args as the parameter, but I got the same error message. her
is the code:
("SiteName" is the name of the dropdown in the form, "SiteID" is a
field in table "Sites", also used as the value in the dropdown.)
protected void SiteName_SelectedIndexChanged(object sender,
EventArgs e)
{
SqlDataSource SiteInfoDS = new SqlDataSource();
DataSourceSelectArguments args = new
DataSourceSelectArguments();
String SelQuery = "SELECT * FROM Sites WHERE (SiteID
=@SiteID)";
SiteInfoDS.ConnectionString = "siteConnectionString";
SiteInfoDS.SelectCommandType = SqlDataSourceCommandType.Text;
SiteInfoDS.SelectCommand = SelQuery;
SiteInfoDS.SelectParameters.Add("siteID",
SiteName.SelectedValue);
DataView dv =
(DataView)(SiteInfoDS.Select(DataSourceSelectArguments.Empty));
foreach (DataRow dr in dv.Table.Rows)
{
AreaName.Text = dr["AreaName"].ToString();
SiteType.Text = dr["SiteTypeName"].ToString();
SiteFinance.Text = dr["FinanceNo"].ToString();
}
}
Thanks for your assistance.
I am new to ASP.NET and VS 2005 Express.
I am having problems with an error message and can't figure out why.
I am trying to run a "SELECT" query triggered by a change in dropdown .
When I hit the line:
DataView dv =
(DataView)(SiteInfoDS.Select(DataSourceSelectArguments.Empty));
in the code below, I get:
"Format of initializaion string does not conform to specification
starting at index 0".
I changed it so DataSourceSelectArguments args = new
DataSourceSelectArguments();
and used args as the parameter, but I got the same error message. her
is the code:
("SiteName" is the name of the dropdown in the form, "SiteID" is a
field in table "Sites", also used as the value in the dropdown.)
protected void SiteName_SelectedIndexChanged(object sender,
EventArgs e)
{
SqlDataSource SiteInfoDS = new SqlDataSource();
DataSourceSelectArguments args = new
DataSourceSelectArguments();
String SelQuery = "SELECT * FROM Sites WHERE (SiteID
=@SiteID)";
SiteInfoDS.ConnectionString = "siteConnectionString";
SiteInfoDS.SelectCommandType = SqlDataSourceCommandType.Text;
SiteInfoDS.SelectCommand = SelQuery;
SiteInfoDS.SelectParameters.Add("siteID",
SiteName.SelectedValue);
DataView dv =
(DataView)(SiteInfoDS.Select(DataSourceSelectArguments.Empty));
foreach (DataRow dr in dv.Table.Rows)
{
AreaName.Text = dr["AreaName"].ToString();
SiteType.Text = dr["SiteTypeName"].ToString();
SiteFinance.Text = dr["FinanceNo"].ToString();
}
}
Thanks for your assistance.