Showing posts with label visual. Show all posts
Showing posts with label visual. Show all posts

Sunday, March 25, 2012

Accessing DB from Webpages or Visual Studio

Ok,

I am a webdesigner who at the moment does not know SQL (although, I plan on remedying that) so I am developing a page with a DB designer - he is doing the DB work, I am doing the look/feel, but he asked me the following questions, of which I cannot seem to find an answer and the guys who tend our server are useless - so I am hoping someone here can help me. In general what he needs to know is:

"what is the external address (either in domain format or IP) and the equivalent internal address so that we can access the msSQL running on your server. The internal address is needed for the webpages to talk to it, while the external address is needed for development of the pages in visual studio and the database tools." Also, he later sent me an email asking that when I get this info (from someone) that it would be usefull to get a sample string/query to get access to the DB. I am running SQL 2000 and have enterprise manager. Where can I find this information? or how do I figure this out?

Thank you for all the help -- Please let me know if you need any more info.

Hey everybody,

I am a webdesigner who currently does not know SQL (although I am working on Remedying that) So as for my question, it comes from the gentleman who I am working with on a new site. What he needs to know is:

"what is the external address (either in domain format or IP) and the equivalent internal address so that we can access the msSQL running on your server. The internal address is needed for the webpages to talk to it, while the external address is needed for development of the pages in visual studio and the database tools."

We are running SQL 2000 with Enterprise manager. On an IIS server. He would also like to get a sample string {? = Query?} for a page accessing the DB.

Any help about where to find this information would be greatly appreciated. If you need to know anything else. Please let me know...

|||http://www.connectionstrings.com/?carrier=sqlserver2005|||There is no internal and external address. I am not quite sure what you mean by that. There is also no querystring in IIS to access the db, you will have to code that for yourself. You can use any coding language and a connectionstring from www.connectionstrings.com. Hars to tell what he wants to know with this information so far.

Jens K. Suessmeyer.

http://www.sqlserver2005.de
|||

The 'internal' address will be the ServerName. The 'external' address will be the port and IP address -that assumes that your firewall allows that port to be open. (I suggest using something other than the default port of 1433 -choose a high number port to use.)

As Jens suggested, the web application should use the correct connectionstring. Hopefully, you will NOT allow something as reckless and dangerous as using a =?Query to pass connection information or sensitive data.

accessing database problem

Hello friends when I am working in VWD and accessing sql data this error came?

I am using asp.net visual web developer edition and sql server 2005 expressedition.

plz check it out and help me.

The log scan number (588:85:1) passed to log scan in database 'D:\GCAP\APP_DATA\GRIET_IT.MDF' is not valid. This error may indicate data corruption or that the log file (.ldf) does not match the data file (.mdf). If this error occurred during replication, re-create the publication. Otherwise, restore from backup if the problem results in a failure during startup.
Could not open new database 'D:\GCAP\APP_DATA\GRIET_IT.MDF'. CREATE DATABASE is aborted.
An attempt to attach an auto-named database for file D:\GCAP\App_Data\GRIET_IT.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.

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: The log scan number (588:85:1) passed to log scan in database 'D:\GCAP\APP_DATA\GRIET_IT.MDF' is not valid. This error may indicate data corruption or that the log file (.ldf) does not match the data file (.mdf). If this error occurred during replication, re-create the publication. Otherwise, restore from backup if the problem results in a failure during startup.
Could not open new database 'D:\GCAP\APP_DATA\GRIET_IT.MDF'. CREATE DATABASE is aborted.
An attempt to attach an auto-named database for file D:\GCAP\App_Data\GRIET_IT.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


Stack Trace:

[SqlException (0x80131904): The log scan number (588:85:1) passed to log scan in database 'D:\GCAP\APP_DATA\GRIET_IT.MDF' is not valid. This error may indicate data corruption or that the log file (.ldf) does not match the data file (.mdf). If this error occurred during replication, re-create the publication. Otherwise, restore from backup if the problem results in a failure during startup.
Could not open new database 'D:\GCAP\APP_DATA\GRIET_IT.MDF'. CREATE DATABASE is aborted.
An attempt to attach an auto-named database for file D:\GCAP\App_Data\GRIET_IT.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.]
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +171
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +199
System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +2406
System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK) +34
System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64 timerExpire, SqlConnection owningObject) +223
System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String host, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, Int64 timerStart) +371
System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) +184
System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) +193
System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) +501
System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) +28
System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) +429
System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) +70
System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) +510
System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +85
System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +89
System.Data.SqlClient.SqlConnection.Open() +159
System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +118
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +139
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable) +82
System.Web.UI.WebControls.SqlDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) +1653
System.Web.UI.WebControls.ListControl.OnDataBinding(EventArgs e) +82
System.Web.UI.WebControls.ListControl.PerformSelect() +18
System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +68
System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +61
System.Web.UI.WebControls.ListControl.OnPreRender(EventArgs e) +26
System.Web.UI.Control.PreRenderRecursiveInternal() +88
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5684



Version Information: Microsoft .NET Framework Version:2.0.50727.832; ASP.NET Version:2.0.50727.832

Hi radhekrishna,

The error message indicates that either the database file you are trying to attached has already been attached in sql express or there is data corruption in your database file(.mdf file) , thus the db file could not be attached. I would suggest you connect to your sql express server through management studio to make a verification (Note here that since Sql Express use customer instance, in management studio, you must login using the same account as the one you used in your application). If that db file has been attached, detach it and take another try.

If there is no such file attached already in your sql express, I would suggest you first attach that mdf file to your database. If you still get this error, it means that the mdf file is data corrupted (information in ldf file and mdf file does not match) and cannot be used anymore--You need to restore it then.

Hope my suggestion helps

Accessing Data directly from a SqlDataSource?

First let me give you a little back ground on me. I'm very new to the ASP, ASP.NET, Visual Studio, Sql Server, Frameworks...thing. I am coming over from a PHP/MySql background of over 5 years. The change over to VBScript and VB has been to tough and I have a basic liking for the Visual Studio 2005 and the ease of putting things together. However, I have come across something that to me seems like it should be relatively simple, but haven't been able to find the documentation or samples to describe what I'm looking to do.

Rough Need:

1. Start with a form will a couple labels and a singe textbox to get the lookup date from an user.

2. Query one table/view based on the users choice of date and select only one field of returned data.(Doing this by itself is not a problem and I can display my results in a Gridview, but this is where it starts getting tricky and the gridviews won't work for me.)

3. If there is something returned, I need to start a HTML table layout or possibly some form of a Gridview(I don't see how I would use the Gridview) and start a loop, adding the first returned row from this query into the first cell.

4. Now, based on that same User Date and the returned row value from the previous query, I need to query another Table/view and return another single field, which might return 1 or multiple rows, which I need to start a loop to display unique items in cells under the first on above.

5. Based on the original User Date and each returned row from the first query, I need to query two other Table/views and get some additional information. 4-5 fields will be returned and be displayed on one row in the number of necessary columns.

6. This would finish the first row from the first query, so I would need to loop back up to see if there were any further results and continue looping until the get to the last of the results from the first query.

7. Finally, I would just need to close up the Table/gridview.

The basic results I'm looking for would be similar to the following:

Results for 10/11/2005

Field name 1Field name 2Field name 3Field name 4Field name 5

First Result from query 1
1 of 4 results from Query 2, but only 1 unique result

Info from Query 3

Info from Query 3

Info from Query 3

Info from Query 4Info from Query 4Info from Query 3Info from Query 3.

Info from Query 3

Info from Query 4
Info from Query 4Info from Query 3

Info from Query 3

Info from Query 3

Info from Query 4
Info from Query 4Info from Query 3Info from Query 3

Info from Query 3

Info from Query 4Info from Query 4

Second Result from query 1
First result from Query 2 after looping though the first query
Second result from Query 2 after looping though the first query
Info from Query 3

Info from Query 3

Info from Query 3

Info from Query 4Info from Query 4Info from Query 3Info from Query 3.

Info from Query 3

Info from Query 4
Info from Query 4Info from Query 3

Info from Query 3

Info from Query 3

Info from Query 4
Info from Query 4Info from Query 3Info from Query 3

Info from Query 3

Info from Query 4Info from Query 4

It seems me from what I have read and slowly figuring out, is that I should be able to directly access the DataSet returned by four SqlDataSources, one for each of the above querys and then just write my own VB to handle the necessary looping, table format and such. I can easily add the for SqlDataSources to the page and add a Gridview for each one and get 4 separate chunks of info, but can't see a way with GridViews to intermingle the info like displayed above.

So, if it can be done with Gridviews, then I would love to see how that is done. But, if someone could explain to me how I access the DataSets directly that I get from the 4 SqlDataSources, then that would be ok too. I have figured enough out with VB, that I can write the code to do my looping requirements, if I can just access the information I get back. Thanks for reading all the way through this long post.

Jack

First let me apologize for the mis-spellings and the two links in my sample layout. I did some copy-n-pasting, then changed the wording, but forgot to remove the link behind. I didn't see any way on this forum to be able to Edit my own post to make the necessary corrections.

Second, is this as big of a problem as it seems, since know one made any replies to it? From what little research I've done, it looks like this should be possible with nested Repeaters, but I just can't seem to figure out how to put it all together so that the second SqlDataSource can use each returned value from the results of the first SqlDataSource to get the next set of records and then again with the third and fourth SqlDataSources.

If someone could just give a very short example of a form with a single texbox and submit button, that on postback, you could manually loop through the results returned by a single field onto the page, then I think that would give me some direction here. This is one of those cases that I don't think I want to use a Control to display the returned information, I just need to know how to manually access that returned info. Thanks again.

Jack

Thursday, March 22, 2012

Accessing AdventureWorks DB from ASPNET

Hi folks,

I've been wondering whats the "appropriate" way to configure AdventureWorks DB such that the WHOLE database can be access from Visual Studio and ASPNET webpages.

The problem I keep beating my head against is the schema problem which prevents me from accessing tables with different schema.

What I've done/can do so far is:

1. Installed AdventureWorks DB
2. Can run SQL cmds from Winforms apps and these are working as expected.
3. I've added MACHINENAME\ASPNET to the database. The default schema is "dbo".
4. The DB is running on the same server as the web server.
When I try to execute something trivial such as:

SqlConnection connection = new SqlConnection("Data Source=localhost;Initial Catalog=AdventureWorks;Integrated Security=true;");

try

{

connection.Open();

SqlCommand command = new SqlCommand("SELECT * FROM [Production.Product]", connection);

SqlDataReader reader = command.ExecuteReader();
...
To get the above to work I need to set the ASPNET users schema to Production.

I will admit I am a novice when it comes to SQL Server but I'm learning fast.

Can anyone help?

Short of trawling through a ton of code what was Microsofts intended usage of schema and how would one access tables located in multiple schemas from ASPNET.

Thanks,

Philip.

See the response at http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=166975&SiteID=1

Tuesday, March 20, 2012

Accessing a Microsoft Access database from within Visual C++

Hi there guys, I am currently trying to achieve a seemingly simple task in VC++ 2005. I have made a very simple form in Microsoft Access which I wish to serve as the beginnings of something greater. I created a db in MS Access named links.mdb containing on table-> Table1. Table1 contains 1 column, "Links", and i wish to read these strings into variables in my Visual C++ Windows Forms Application.

What I have done so far...

In Visual C++, I clicked on Data->Add new data source, and followed the wizard to add the microsoft access database to my application by the name, "linksDataSet". I can see the table in my left hand "Data Sources" pane in VC++. All I need to know is how to access my database from here so that I can read these strings stored in my table. Also, would be possible to schedule my application to log on to a http server and retrieve these links every time the application is executed? How would I go about doing this?

Thank you very much for your time
Regards
Linden.Umm... hi, my topic has been moved into this forum, even though I don't think it belongs here because my question is VC++ database related but can anyone help me? I would greatly appreciate it.|||44 Views and not one reply? Is this not a familiar concept?|||This is ridiculous! Why is this forum here? It obviously serves no purpose.|||

To read a Microsoft Access database table from VC++ 2005:

1. First I created a new Windows Console project in VC++.

2. Then Project | Add Class... then go under ATL and choose ATL OLEDB Consumer.

3. Click Data Source and choose Microsoft Jet 4.0 OLEDB Provider, Next>>> then type in database name.

4. Click OK, another dialog comes up, choose your table, it will create a single class for your table.

Then the code to read the data is like so:

#include "stdafx.h"

#include "Table1.h"

int _tmain(int argc, _TCHAR* argv[])

{

CoInitialize(NULL); // Be sure to initialize COM somewhere in your app one time...

CTable1 table1;

HRESULT hr = table1.OpenAll();

for(;;)

{

hr = table1.MoveNext();

if (S_OK != hr) break;

printf("table1.f1=%lu\n", table1.m_f1);

printf("table1.f2=%S\n", table1.m_f2);

}

return 0;

}

|||I am currently working in a windows forms application, how would the code change?

Sunday, March 11, 2012

Access to SQLServer Database from Visual C# app and ASP.NET app

I've created a visual C# GUI that logs data over a LAN. The GUI is for Admin purposes only so it logs data and stores it (plus some admin stuff). The data that is logged is supposed to be served up to anyone on the network as a web app. I've got an instance of SQLServer running and the GUI works great but I can't seem to get the web app to connect to the database to read and display the data for general users?

I'm new to ASP.NET and SQL Server so a little extra explanation or steps that I'm missing wouldn't hurt me if you have the time to spare.

I get an error that says "Cannot get web application service" in Visual Studio when I try and drag and drop a SQLDataSource onto my pages and configure it. It then asks me to Choose My DataConnection from the drop down and there's no connection there...

I tried setting it up in the code behind page like I would in Visual C# (small code example below) by adding in using System.Data.SqlClient; etc.. and it throws me a nasty notice (see below). Obviously it doesn't like this user but how do I fix this so I can server up my DB to work for both my GUI and ASP apps? I noticed when looking at my DB that the owner is TUDOR\Windows is there a way to have multiple owners to a DB if this is what's wrong?

String conn = @."Server=TUDOR\sqlexpress;" +

"Integrated Security=True;" +

"Database=ATSDB";

// Specify SQL Server-specific connection string

SqlConnection dbconn = new SqlConnection(conn);

// Create DataAdapter object

SqlDataAdapter dbadpt = new SqlDataAdapter("SELECT FirstName FROM tblPersonInfo WHERE FirstName = 'Kim'", dbconn);

// Create CommandBuilder object to build SQL commands

SqlCommandBuilder dbcmd = new SqlCommandBuilder(dbadpt);

// Create DataSet to contain related data tables, rows, and columns

DataSet dbset = new DataSet();

// Fill DataSet using query defined previously for DataAdapter

dbadpt.Fill(dbset, "tblPersonInfo");

Server Error in '/ATS' Application.

Cannot open database "ATSDB" requested by the login. The login failed.
Login failed for user 'TUDOR\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: Cannot open database "ATSDB" requested by the login. The login failed.
Login failed for user 'TUDOR\ASPNET'.
Source Error:
Line 32: Line 33: // Fill DataSet using query defined previously for DataAdapter Line 34: dbadpt.Fill(dbset, "tblPersonInfo"); Line 35: } Line 36: }

Source File: c:\Inetpub\wwwroot\ATS\text\Default2.aspx.cs Line: 34 Hi there,

ASP.NET web applications, by default, will run under their own account. In your case, this account seems to be TUDOR\ASPNET.

The problem seems to be that this account is not set up as a login in SQL Server. You need to create a login for TUDOR\ASPNET for your SQL Server and give it access to the required databases.

You can do this by (sorry if you already know this bit):

1) Open Management Studio Express (I presume from reading your code that you are using SQL Server Express Edition) and connect to your SQL Server Instance

2) Expand the node for your SQL Server instance and you will see a node labelled "Security"

3) Right click on the "Security" node and select "New > Login" from the context menu that appears

4) A new dialog window will appear. Enter "TUDOR\ASPNET" as the user and make sure that the Windows Authentication radio button is selected. Set the default database as required (in your case this will probably be ATSDB)

5) In the dialog, on the left hand side there should be an item called "Server Roles". Click on this and then define whatever server roles (e.g. sysadmin) TUDOR\ASPNET will have....What roles the user'll have is entirely up to you

6) In the dialog, on the left hand side there should be an item called "User Mapping". Click on this and then select which databases TUDOR\ASPNET will have access to (in your case, most definately select ATSDB). Also, select what database role (e.g. dbowner) the account will have....Once again, this is up to you to determine

7) Nothing else is particularly interesting so just click OK to finish the process

After you have given access to TUDOR\ASPNET to your SQL Server, you should be able to use your ASP.NET application without getting that error.

Hope that helps a bit, but sorry if it doesn't
|||That sounds like exactly what I need to do. I am using Sql Server Express, from what I've read that is what comes with Visual Studio 2005 but I can't find Management Studio Express? Is that something that only comes with Express Edition software? When I was asked to do this I went out and bought some O'Reilly books but I also bought a couple Express Edition books so I could get up and going fast so if the code looks unelegant that might be why or maybe it was the /SQLExpress that gave it away. Thanks for all the notes I didn't know how to do all that and if I can find Management Studio Express that would definetly solve all my problems. Is it under something else in Visual Studio 2005 Pro Edition?|||Hi there,

Management Studio Express is a seperate download. You can get it from the below link.

SQL Server Express Edition Downloads

After you download & install it, you should be good to go. When Management Studio asks you to connect, your server name, by reading your code should be TUDOR\SQLEXPRESS.

Using Management Studio Express you can connect via SQL Server Authentication (using an account like "sa") or Windows Authentication. If you connect via Windows Authentication but find you can't modify users then your account probably does not have the required privileges. If you switch to the "sa" account you should be fine.

Hope that helps a bit.
|||Thanks so much for your help and your explanations. That's a lot of typing to do to help out someone you don't know. Much appreciated. Works great.

Tuesday, March 6, 2012

Access to fields in a table

I am trying to access the fields in a table using Visual Basic in Web Developer .NET

Start with the link below and click on SelectCommand, InsertCommand, DeleteCommand and UpdateCommand to get tbe basic of manipulating data in the database through ADO.NET. Hope this helps.

http://msdn2.microsoft.com/en-us/library/system.data.sqlclient.sqldataadapter.aspx

Saturday, February 25, 2012

Access SMO objects in CLR proc

I would like to write some CLR procs that use SMO objects. In visual studio I am unable to add refrences to the SMO objects. How can I do this?

Thanks

Bert

Because CLR was designed to work within the SQL Server engine the references available for a CLR assembly are limited. The assemblies actually run within the SQL Server context, not as operating system processes.

What would you want to do using SMO that you can't do using Transact-SQL?

|||

You are unable to add them because SMO is dependent on Batchparser90.dll which is half managed/half unmanaged code, so SQL server will not load it. They don't show up in visual studio for this reason.

If you want to use assemblies that don't show up, try creating just a normal class library and then use the CREATE ASSEMBLY T-SQL command. You will have to load all of your external assemblies as well, so I would see if they load before you start writing it, as some will and some wont.

Access SMO objects in CLR proc

I would like to write some CLR procs that use SMO objects. In visual studio I am unable to add refrences to the SMO objects. How can I do this?

Thanks

Bert

Because CLR was designed to work within the SQL Server engine the references available for a CLR assembly are limited. The assemblies actually run within the SQL Server context, not as operating system processes.

What would you want to do using SMO that you can't do using Transact-SQL?

|||

You are unable to add them because SMO is dependent on Batchparser90.dll which is half managed/half unmanaged code, so SQL server will not load it. They don't show up in visual studio for this reason.

If you want to use assemblies that don't show up, try creating just a normal class library and then use the CREATE ASSEMBLY T-SQL command. You will have to load all of your external assemblies as well, so I would see if they load before you start writing it, as some will and some wont.

Sunday, February 19, 2012

Access or SQL Server

Hi,
I am writing a Visual Studio.NET client server app that will reside on one
PC, the GUI, Business Logic and Database. I am trying to decide which
database to use, either SQL Server/ Express or use Access with JET engine.
The database on this PC will be
also be accessed by remote PC's to generate reports.
I'm not sure the exact Pros and Cons of both databases.
I'd appreciate suggesstions as to the pros and cons of each database to help
decide which database to use.
Thanks In Advance,
MaccaHi,
http://www.microsoft.com/sql/soluti...are-access.mspx
HTH, Jens Suessmeyer,|||Macca wrote:

> Hi,
> I am writing a Visual Studio.NET client server app that will reside on one
> PC, the GUI, Business Logic and Database. I am trying to decide which
> database to use, either SQL Server/ Express or use Access with JET engine.
> The database on this PC will be
> also be accessed by remote PC's to generate reports.
> I'm not sure the exact Pros and Cons of both databases.
> I'd appreciate suggesstions as to the pros and cons of each database to he
lp
> decide which database to use.
> Thanks In Advance,
> Macca
Please do not multi-post!
I replied in microsoft.public.sqlserver.server
David Portas
SQL Server MVP
--|||> I am writing a Visual Studio.NET client server app that will reside on one
> PC, the GUI, Business Logic and Database. I am trying to decide which
> database to use, either SQL Server/ Express or use Access with JET engine.
Access has several limitations that I document here:
http://www.aspfaq.com/2195|||Thanks,
Macca
"Jens" wrote:

> Hi,
> http://www.microsoft.com/sql/soluti...are-access.mspx
> HTH, Jens Suessmeyer,
>|||Thanks,
I want to use SQL Server. This will help,
Macca
"Aaron Bertrand [SQL Server MVP]" wrote:

> Access has several limitations that I document here:
> http://www.aspfaq.com/2195
>
>

Access MSDE From VS 2003 Server Explorer

Not sure if this is a MADE or Visual Studio issue, but here goes:
I have MADE and SQL Server GUI tools installed (GUI from Developer Edition)
to support database app development with Visual Studio .NET 2003 (VS 2003).
I have the sample databases installed (pubs, North, etc.) via an executable
file ConfigSamples.exe which includes TO-SQL scripts to create the sample
databases then populate the tables with data.
Because ConfigSamples.exe is not "a known archive type" I cannot get inside
to see the TO-SQL scripts to discover how these databases are made to not
demand user authentication in VS 2003 Server Explorer.
From VS 2003, I can see my MADE instance and the databases, and access them
via Server Explorer or from .NET apps I develop/evaluate. So far, so good.
Now the issue:
I need to create new databases in conjunction with various projects, and
have done so successfully using the SQL Server GUI tools, and from TO-SQL
scripts. When I create the new database, Enterprise Manager and Query
Analyzer allow my access to do whatever I want with the database.
Not so in VS 2003 Server Explorer! the new database does show up in the list
of databases under the MADE instance, but when I try to expand the new
database node, up pops a dialog asking for a Username and Password, or
offering me the choice of using Win NT Authentication. No answer I provide
to this dialog gives me access to the database. Choosing NT Authentication
gets me another dialog with *no message text* and only an OK button to
click, and trying any ID/password combination gets me a message indicating
it's not acceptable.
I should say that I'm running using full administrative privileges.
So the question is: how can I create a database like the sample databases
that can be accessed in Server Explorer? Is there a way to turn off the
security check?
Disclaimer: I'm not a SQL Server jock (obviously) and am using the software
and databases to teach college classes and evaluate student projects, so try
to keep it fairly simple?
Thanks in advance for any insights.
Arrrrgh!!
Somehow all instances of "MSDE" in my post were changed to "MADE", could
have sworn I clicked "Ignore" in the spell checker. Sorry!

Thursday, February 9, 2012

access denied for user <machine name>\ASPNET

Hi!

I've just started to learn to use Visual Studio, and has come to database access.
I ran into this errormessage:

access denied for user <machine name>\ASPNET

The book I'm using just only say that I have to grant the ASPNET user account permissions before the Web application will have access to a SQL database. ... Seems clear at first glance ... but I lack a "how to" ...!

--

I've tried to search the net for solutions ... several thousands of pages came up ... indicating that I'm far from the first who have this problem. ... So after I now have spend hours reading, without finding any useful ansver to the question. ...

So let me just tell the most popular answers. (So You don't repeat something I allready have read hundreds of times.):
This question has been asked before
Yes, true answer, but it doesn't help.

See the FAQ
If it was stated were in the FAQ to look it could have been useful.

Use something called "enterprise manager" (WIN XP pro, don't have this, though.)
I use WIN XP pro, so that answer dosn't help me either.

--

Hope some one can help.Do you have SQL Server installed on the machine in question? If so, Enterprise Manager will be there (it will run fine on XP pro). You will not have Enterprise Manager if you have MSDE, in which case you need to use osql.exe:

This article explains various ways to work with MSDE. Note that the "Grant permissions to the ASPNET account" is the section to do what you need to do, given your current connection string.|||Yes, I have this osql.exe program. But when I try to use it, it comes up with an access denied error message.

I found another solution to the problem: Moving the ASPNET user from "Restricted user" to "Administrators".

I was a bit hesitant to do this at first (At first glance it appears a bit unsafe to do so.), but when I realized that it is commonly done that way, and when I tried it myself everything did run as it was supposed to. (So ... problem solved!)|||This is areally, really bad idea. The reason MS used the restricted account by default is to make your machine secure. Moving the ASPNET user to the Administrators group is aterrible idea.

Just cause it works, does not mean it is correct.|||Let me reiterate what Doug just said.

Moving the ASPNET user to the Administrators group is a terrible idea.

Don't do it! If someone manages to compromise your server through your website (such as through a SQL injection exploit) they will have unlimited access to run/install/ruin whatever they want on the machine.

Terri