Link to home
Start Free TrialLog in
Avatar of forsters
forstersFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Keyword not supported: 'sqldatasource'.

Hi Folks,

Been learning my way round Visual Studio 2010, asp.net 4.0 & C# and am stuck on something silly.
I'm trying to add a drop-down list which is databound to a table in my sql database - as far as I can tell from my book etc I've done things right but as soon as I reference my DataSourceID in the dropdownlist I get an error:
Keyword not supported: 'sqldatasource'.
Not sure what I'm missing?
BELOW: THE CODE IN MY PAGE
 <asp:DropDownList 
    ID="DropDownList1"
    DataSourceID="MyDataSource"
    AppendDataBoundItems="true"
    DataTextField="Description"
    DataValueField="OptionID"
    runat="server">
    </asp:DropDownList>
   
    <asp:SqlDataSource ID="MyDataSource"
     ConnectionString="<%$ connectionStrings:Scanning %>" 
     SelectCommand="Select * From [JobType]" 
     runat="server">
    </asp:SqlDataSource>
PAGE BEHIND CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Data.SqlClient;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class JobRequest : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
}
WEB CONFIG CONNECTIONSTRINGS:
<connectionStrings>
		<add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient"/>
		<add name="Scanning" connectionString="SqlDataSource=servername; Initial Catalogue=Repro Tasklist;User ID=IntranetAdmin; Password=censored" providerName="System.Data.SqlClient"/>
    <add name="Intranet" connectionString="SqlDataSource=servername; Initial Catalogue=IntranetDB;User ID=IntranetAdmin; Password=censored" providerName="System.Data.SqlClient"/>
	</connectionStrings>

Open in new window

Avatar of Muhammad Zaman
Muhammad Zaman
Flag of Pakistan image

Hi,

you have to define provider in your sqldatasource queries, select, update, delete etc

providerName="System.Data.SqlClient" as an attribute


Cheers
ASKER CERTIFIED SOLUTION
Avatar of Den_HBR
Den_HBR

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of forsters

ASKER

Ahhh thanks Den HBR you're right it was my connection string format that was causing the problem, I have now changed it to:

<add name="Intranet"
       providerName="System.Data.SqlClient"
connectionString= "server=OUR SERVER;database=OUR DATABASE;uid=USERNAME;pwd=PASSWORD"/>

Brilliant thanks for pointing me in the right direction.