Showing posts with label datagrid. Show all posts
Showing posts with label datagrid. Show all posts

Saturday, February 25, 2012

AspX Page Connection Error using sqlserver

Dear i am using visual studio.net........ when i connect database (in sqlserver) using sqldataAdapter with datagrid in visual basic.net every thing work properly......... but when i use the same in asp.net then i get an error message on the resultant explorer page give below.

Server Error in '/studentData' Application.
------------------------

Login failed for user 'RAMIZSARDAR\ASPNET'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Login failed for user 'RAMIZSARDAR\ASPNET'.

Source Error:

Line 85: 'Put user code to initialize the page here
Line 86: Dim ds As New DataSet()
Line 87: SqlDataAdapter1.Fill(ds)
Line 88: DataGrid1.DataSource = ds.Tables(0)
Line 89: DataGrid1.DataBind()

Source File: c:\inetpub\wwwroot\studentData\WebForm1.aspx.vb Line: 87

Stack Trace:

[SqlException: Login failed for user 'RAMIZSARDAR\ASPNET'.]
System.Data.SqlClient.SqlConnection.Open()
System.Data.Common.DbDataAdapter.QuietOpen(IDbConnection connection, ConnectionState& originalState)
System.Data.Common.DbDataAdapter.Fill(Object data, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)
studentData.WebForm1.Page_Load(Object sender, EventArgs e) in c:\inetpub\wwwroot\studentData\WebForm1.aspx.vb:87
System.Web.UI.Control.OnLoad(EventArgs e)
System.Web.UI.Control.LoadRecursive()
System.Web.UI.Page.ProcessRequestMain()

------------------------
Version Information: Microsoft .NET Framework Version:1.0.3705.0; ASP.NET Version:1.0.3705.0

Plz solve my problem and Reply me on ramiz_ch@.hotmail.com
Plz solve my problem and Reply me on ramiz_ch@.hotmail.com
Plz solve my problem and Reply me on ramiz_ch@.hotmail.com

Ramizwell, yes. if you use the same code in VB.NET/WIndows forms it'll run under the security context of the currently logged-in user. i.e. YOU.

under ASP.NET it runs by default as the ASP.NET guest account, MACHINENAME\ASPNET

you need to add ASPNET to the SQL Server permissions list, OR run ASP.NET as a different user, OR specify a SQL Server auth account in your connection string.

this question has been covered over and over in these forums. try the FAQ, if it's not in there I'll be shocked and amazed.

Monday, February 13, 2012

ASP.NET SQL CONTAINS statement

I have an SQL db that I need to be able to search and display. I haveabout seven different columns and would like results to be returned toa datagrid based upon the search criteria entered by the user.
How do I construct a SELECT statement such as below using the ASP.NET 1.1+?
SELECT * FROM db.table WHERE CONTAINS ("searchable term")
I can get a column searched and return the results already, but if Imodify to search all columns and use the CONTAINS it will fail. Isthere a way to do this easily?
Thanks,
TRKneller

Your query is failing because you are using CONTAINS Microsoft Proprietry FULL TEXT search predicate when you need to use LIKE which is ANSI SQL used to search table column based data. Full Text is used for Text and NText data but it is an add on to SQL Server dependent on Microsoft Search Service and the Catalog must be populated to get search results. SQL Server creates an Arithmetic Pointer to Text and NText data in your file system. Run a search for LIKE and FULL Text in the BOL(books online). Hope this helps.

Sunday, February 12, 2012

ASP.NET DataGrid Problem

Hi,

As a relative newbie to SQL Server/ASP.NET I'm hoping someone here
can help with my problem. I'm developing a timesheet application in
ASP.NET C# using Visual Studio 2003 with a database built in MSDE.
One of my forms needs to return a simple list of resources from my
database. I have followed the guide on the MSDN libraries, but for
some reason I continuously get the same error message.

What I've done so far is Create the database, tables, and populate
with some sample data using using Server Explorer in Visual Studio. I have
connected to the database (using integrated security) and I am
trying to get the contents of the Resource table to appear on my
form. I have then created a DataAdapter (tested the connection, set
the SQL as a simple SELECT * from Resource, etc), which also generates an sqlConnection for me. To test this I have previewed the generated data, and it returns what I want, so I
have chosen to generate a DataSet of this. I am then trying to get
this data into a simple DataGrid. On the properties of the DataGrid
I have changed the DataSource to point at my Dataset. As I
understand it, I then have to add the following to my Page Load
section of my code.

sqlConnection1.Open();
this.sqlDataAdapter1.Fill(this.dsResource);
DataGrid1.DataBind();
sqlConnection1.Close();

The form builds fine, but when I browse to the particular form I get
the following error for the sqlConnection1.Open(); line. If I remove this line the error simply moves to the line below.

Exception Details: System.Data.SqlClient.SqlException: Cannot open
database requested in login 'SCMS'. Login fails. Login failed for
user 'AL-NOTEPAD\ASPNET'.

To me this is an error with my connection string. My database
instance is actually 'AL-NOTEPAD\VSDOTNET'. However the properties
for sqlConnection1 are pointing to the correct datasource. I do not
know why the application is looking for user 'AL-NOTEPAD\ASPNET'. It does not exist, to my knowledge. Do I need to grant access to this user? If so, how would I do it? Bearing in mind I am using MSDE, and do not have Enterprise Manager.

Any help with this would be greatly appreciated, as I get the same
error with my code for forms-based login...


Thanks in advance..

Hi there, welcome to the ASP.NET Forums!

The root of the problem is that Visual Studio will use *your* credentials to log in to the SQL Server and access the database when you are using integrated security. However, when you run the site through a web server, it will use the ASPNET account. And, as you are experiencing, the ASPNET account does by default have those needed permissions.

To solve this problem, you have 2 options. You can use impersonation in your web.config, so that your web application will impersonate whatever user you desire (which presumably has permissions to your SQL Server and database). Or, you can grant the needed permissions to the ASPNET account.

Seethis post for instructions on how to grant the needed permissions to the ASPNET account.|||

Hi,

Thanks for all the help, I've sorted the problem in the short term by
downloading an MSDE alternative to Enterprise Manager
(http://www.asql.biz/DbaMgr.shtm) and assigned the relevant access to
the ASPNET user account. The DataGrid now works.

Thanks again

Al

ASP.NET datagrid as datasource

Hello, I've got an ASP.NET project that populates a datagrid depending
on the search criteria of the end-user. I'd like to take the populated
datagrid as my datasource for my report. Can anyone shed some light on
how to do this or point me in the right direction.
Thanks in advance.You should investigate the new controls with VS 2005. For those you give a
table and a report and the control renders it (no server) if using in local
mode.
Bruce Loehle-Conger
MVP SQL Server Reporting Services
"gallan" <gregallan@.tvl.com> wrote in message
news:1148401708.679329.228750@.j55g2000cwa.googlegroups.com...
> Hello, I've got an ASP.NET project that populates a datagrid depending
> on the search criteria of the end-user. I'd like to take the populated
> datagrid as my datasource for my report. Can anyone shed some light on
> how to do this or point me in the right direction.
> Thanks in advance.
>