Showing posts with label sqlclient. Show all posts
Showing posts with label sqlclient. Show all posts

Friday, March 23, 2012

Help on Displaying Data from sqldatasource as Microsoft SQL Server (SQLClient)

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NWHCConnectionString %>"
SelectCommand="SELECT * FROM [AI_news]" OnSelecting="SqlDataSource1_Selecting">
</asp:SqlDataSource>

This is my code, I have followed the wizard perfectly the way its supposed ot be, well not 100% perfectly. This is how its supposed to be. When using a XXXX.MDF file I could use the wizard and it works fine. I do not know why my above code won't work. I am connected to the database and can view code manually. but not on a aspx page.

i am using master page, now trying to add this into default.aspx

Any help will be appreciated. I am currently losing some hair.

How are you trying to display the data? Have you bound a GridView to the SqlDataSource control? If not, add this:

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="True" DataSourceID="SqlDataSource1"></asp:GridView>

|||

I forgot to add a few things,

I am using Microsoft SQL Server (SqlClient).

with this code

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NWHCConnectionString %>"
SelectCommand="SELECT * FROM [AI_news]" OnSelecting="SqlDataSource1_Selecting">
</asp:SqlDataSource>

The code below compile fine, but doesn't show any results.

When I use Mikesdotnetting code, I receive this message.

The DataSourceID of 'GridView1' must be the ID of acontrol of type IDataSource. A control with ID 'SqlDataSource1' couldnot be found.

Lastly, I did not add anything in my webconfig file.

I will be working on this page while waiting for support.

|||

You need both on the page at the same time. The SqlDataSource only fetches the data. The GridView is what displays it.

I suggest you take the time to acquaint yourself with the basics. http://www.asp.net/learn/

Drag, drop and fingers crossed won't get you very far.

|||

What I am trying to do here is to display whatever information that is necessary to work from the database. I want to see if the data would at least work, I do not see any data displayed yet regardless how its displayed.

I will look into the tutorials


Monday, March 19, 2012

Help Needed!! Error connecting to SQL 2005 EE via VB 2005 EE

System.Data.SqlClient.SqlException was unhandled
Class=20
ErrorCode=-2146232060
LineNumber=0
Message="An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)"
Number=2
Server=""
Source=".Net SqlClient Data Provider"
State=0

Hi guys, I have just set up a database in SQL 2005 Express Edition. However, I have a problem accessing it with the application program created in VB 2005 EE. Before using SQL 2005, the application worked perfectly in SQL 2000.
Here is my connection string used in SQL 2000:

Dim sqlConn As New SqlConnection("Data Source=(local); Database='Inventory List'; Integrated Security=yes")

Is this valid in SQL 2005 Express Edition? Or should I change the connection string instead? Thank you very much.

The normal connection string for express would be;

Dim sqlConn As New SqlConnection("Data Source=(local)\sqlexpress; Database='Inventory List'; Integrated Security=yes")

|||Did you enable remote connections for the SQL Express instance ? See the Screencast on my site for more information.

Jens K. Suessmeyer.

http://www.sqlserver2005.de