0

Hello i need bit help here, i am getting errors and it says namespace or assembly not included.. please let me know what dll file or what file i am missing ?

FRONTEND ( Code that is in aspx.cs file)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.Common;
using Microsoft.SqlServer.Server;
using System.Data.SqlClient;

public partial class _Default : Page
{
    Database db = DatabaseFactory.CreateDatabase("TSMTEMP");
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        try
        {
            Dbcommand cmd = db.GetStoredProcCommand("search");  // 1 Error Fixed.
            db.AddInParameter(cmd, "@website", DbType.String, TextBox1.Text);
            DataSet ds = db.ExecuteDataSet(cmd);
            Gridview2_srch.DataSource = ds;
            Gridview2_srch.DataBind();
        }
        catch (Exception)
        {
        }

    }
}

BACKEND ( SQLSTOREDPROCEDURE)

create procedure search
@website nvarchar(50)
As
select A.website from website A
inner join category B ON A.website=B.website
inner join contact C ON A.website=C.website
inner join traffic D ON A.website=D.website
where A.website=@website

Here are specific error details:

Error      1              The type or namespace name 'Database' could not be found (are you missing a using directive or an assembly reference?)    C:\xxxxxxxxxx\Default.aspx.cs 14           5                WebSite1(1)
Error      2              The name 'DatabaseFactory' does not exist in the current context                C:\xxxxxxxxxxxxxx\Default.aspx.cs 14           19           WebSite1(1)
Error      3              The type or namespace name 'Dbcommand' could not be found (are you missing a using directive or an assembly reference?)    C:\xxxxxxxxxxxxx\Default.aspx.cs 23           13                WebSite1(1)
Error      4              The name 'Gridview2_srch' does not exist in the current context                C:\xxxxxxxxxx\Default.aspx.cs 26           13           WebSite1(1)
Error      5              The name 'Gridview2_srch' does not exist in the current context                C:\xxxxxxxxx\Default.aspx.cs 27           13           WebSite1(1)

Web.config file code:

<?xml version="1.0" encoding="utf-8"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
  <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  <!-- Added by ankit -->
    <section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings,Microsoft.Practices.EnterpriseLibrary.Data, Version=4.1.0.0, Culture=neutral"/>

  </configSections>
  <dataConfiguration defaultDatabase="TSMTEMPConnectionString" />  <!-- added my ankit-->
  <connectionStrings>
    <add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-WebSite1(1)-20130723110448;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-WebSite1(1)-20130723110448.mdf"
      providerName="System.Data.SqlClient" />
    <add name="TSMTEMPConnectionString" connectionString="Data Source=vlmzazwds4.database.windows.net;Initial Catalog=TSMTEMP;User ID=TSM1;Password=TSModule001!"
      providerName="System.Data.SqlClient" />

  </connectionStrings>
  <system.web>
    <compilation debug="false" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5" />
    <pages>
      <namespaces>
        <add namespace="System.Web.Optimization" />
      </namespaces>
      <controls>
        <add assembly="Microsoft.AspNet.Web.Optimization.WebForms" namespace="Microsoft.AspNet.Web.Optimization.WebForms" tagPrefix="webopt" />
      </controls>
    </pages>
    <authentication mode="Forms">
      <forms loginUrl="~/Account/Login" timeout="2880" defaultUrl="~/" />
    </authentication>
    <profile defaultProvider="DefaultProfileProvider">
      <providers>
        <add name="DefaultProfileProvider" type="System.Web.Providers.DefaultProfileProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" applicationName="/" />
      </providers>
    </profile>
    <membership defaultProvider="DefaultMembershipProvider">
      <providers>
        <add name="DefaultMembershipProvider" type="System.Web.Providers.DefaultMembershipProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" />
      </providers>
    </membership>
    <roleManager defaultProvider="DefaultRoleProvider">
      <providers>
        <add name="DefaultRoleProvider" type="System.Web.Providers.DefaultRoleProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" applicationName="/" />
      </providers>
    </roleManager>
    <!--
            If you are deploying to a cloud environment that has multiple web server instances,
            you should change session state mode from "InProc" to "Custom". In addition,
            change the connection string named "DefaultConnection" to connect to an instance
            of SQL Server (including SQL Azure and SQL  Compact) instead of to SQL Server Express.
      -->
    <sessionState mode="InProc" customProvider="DefaultSessionProvider">
     <providers>
        <add name="DefaultSessionProvider" type="System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" />
      </providers>
    </sessionState>
  </system.web>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="DotNetOpenAuth.Core" publicKeyToken="2780ccd10d57b246" />
        <bindingRedirect oldVersion="1.0.0.0-4.0.0.0" newVersion="4.1.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="DotNetOpenAuth.AspNet" publicKeyToken="2780ccd10d57b246" />
        <bindingRedirect oldVersion="1.0.0.0-4.0.0.0" newVersion="4.1.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
  </entityFramework>

</configuration>
2
  • WHAT are those errors that yo're getting?!? We can't read your screen - nor your mind - you'll have to tell us so we can possibly diagnose a problem... Commented Jul 23, 2013 at 9:14
  • Please show the GridView markup, not complete but just the property sections. Commented Jul 23, 2013 at 10:08

2 Answers 2

3

Your procedure's name is search not Proc_search

Dbcommand cmd = db.GetStoredProcCommand("search");
Sign up to request clarification or add additional context in comments.

3 Comments

wow Great ! Let me try that error fix how that solves something out !
@JohnKim If it works for you, don't forget to accept the answer to avoid low accepted rate an close the question. You can also vote for the answer ;)
@JohnKim Show us you connection string
0

I think you are using Data application block or enterprise library for adding/retriving data make sure you have added the reference and put required namespaces. For example for db.GetStoredProcCommand you need the Microsoft.Practices.EnterpriseLibrary.Data name space

See the following link. http://msdn.microsoft.com/en-us/library/bb748721(v=pandp.31).aspx

So make sure you have proper namespace in your using section.

Regards,

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.