0

I have a database at location xmachina\sqlexpress named News, News has a table NewsTable. How do I tell ASP to look at News database? Is it part of the SelectCommand? Or a webconfig variable?

Right now I get a [SqlException (0x80131904): Invalid object name 'NewsTable'.]

web.config

<add name="NewsTableConnectionString" connectionString="Data Source=XMACHINA\SQLEXPRESS;Integrated Security=True" providerName="System.Data.SqlClient" />

Default.aspx

<asp:SqlDataSource ID="SqlDataSource1" runat="server" 
   ConnectionString="<%$ ConnectionStrings:NewsTableConnectionString %>"
       ProviderName="<%$ ConnectionStrings:NewsTableConnectionString.ProviderName %>" 
       SelectCommand="SELECT [NewsHeadline] FROM [NewsTable]">
</asp:SqlDataSource>

2 Answers 2

2

use this in your connection string setting in your web.config

Database=News;

See the following site for in depth details: link text

Sign up to request clarification or add additional context in comments.

Comments

1

I needed this "Initial Catalog" attribute

<add name="NewsTableConnectionString" connectionString="Data Source=XMACHINA\SQLEXPRESS;Integrated Security=True;Initial Catalog=News" providerName="System.Data.SqlClient" />

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.