Showing posts with label aspnet. Show all posts
Showing posts with label aspnet. Show all posts

Tuesday, March 27, 2012

Cant get CAST function to work in ASP.NET

I'm trying to do something like this SQL statement. I have a table with a field of date/times.

i.e - 2/27/06 9:55:95 PM Basically there are multiple entries in the table per day.

I want to count the records for particular (hence the CAST) and output the count.

Here it was I had just to see if SQL would work in ASP.NET :

SELECT COUNT(*) AS Expr1
FROM dbo.tblActiveDrums
WHERE [CAST](FLOOR([CAST](NCTimeStamp AS [float])) AS datetime) = '0' OR
NCTimeStamp - [CAST](FLOOR([CAST](NCTimeStamp AS [float])) AS datetime) = '0'

It didn't like the AS references?

Any help would be appreciated.

Remove all the brackets and post if there are any error messages. Shouldn't be.|||You want to count the records for a particular what?

Wednesday, March 7, 2012

Cant Create MSDE Database using ASP.NET Matrix

Hi i am having problems creating a new MSDE database when using the
ASP.NET Web Matrix to create it.
It says to click on New Connection, select SQL Sever Authentication,
add in the username and password and then click create new database.
I get an error though saying
Unable to connect to database server
SQL Server does not exist or access denied
ConnectionOpen(Connect())
Any suggestions?
Perhaps you didn=B4t setup the right network settigns:
http://www.codeproject.com/database/ConfigureMSDE.asp
HTH, Jens Suessmeyer.
|||Nope still doesnt seem to be letting me create a new database through
the ASP.Net Matrix.
I removed and then reinstalled the MSDE following the link you gave me,
then set it up following their stages.
I can create a database through the cmd.exe but still having the
problems with ASP.Net Matrix.
Going to remove and reinstall the .net matrix and see if that works.
|||Hi there, managed to get everything working now. deleted the .net web
matrix and the MSDE off my computer. then reinstalled everything again.
the version of .net web matrix i had seemed to be out of date so maybe
this is what was causing the problem.
Thanks for your help.

Sunday, February 19, 2012

cant connect to sql server 2005 from my asp.net application

Hi

I can't connect to sql server 2005 from my asp.net web page. I seem to be able to connect to it when i run the application from within visual studio but i can't connect to it when i run the application from IIS.

I am new to sql server 2005 express so please bear with me.

The error message i get is:

Cannot open database "Vets" requested by the login. The login failed.
Login failed for user 'OSCAR2K4\ASPNET'.

I don't know where this user OSCAR2K4\ASPNET came from but i looked in sql server 2005 and there he is. In the left hand pane I went to Security and then logins and found oscar2k4\asp.net there. I went to the properties for this user and went to User Mappings. There was no tick next to my Vets database so I added one and ran the application from IIS. I also added the user to every single role in the vets database (including dbowner). I also went into the vets database itself and found the oscar/aspnet user and made sure he was added to every role.

I ran the application again. This time i got a lots of different errors. If the page was trying to run a select procedure I got the error user does not have select permission. If the page was running an SP i got the error or user does not execute permission


I have never had this problem before so I don't understand.

Where did this user come from? Was he created automatically when i configured my database for membership and roles? How do i set up this user so he can access the databsae from IIS.

The only way I could get the application to run from IIS was to go to Security - Logins for sql server and add the oscar2k4\asp.net user to the sysadmin role.

I find this very strange. Naturally i don't want to leave oscar2k4 in sysadmin.

Please help :) I can't upload my website until i fix this

Thanks, andrea

<server>\ASPNET is 'ASP.NET Machine Account', one of the access control lists (ACLs) that are set by default on the Machine.config file and the root Web.config file.

What's the OS version (e.g. Window2000 or Xp) of the box? You can take a look at this articlehttp://msdn2.microsoft.com/en-us/library/ab4e6cky.aspx

Cant connect to sql server 2000 from asp.net

I installed sql server 2000 on a remote server. I can connect toit from the client with query analyzer, but I cannot connect to it fromASP.NET. I'm using Sql authentication, and the account has everypermission under the sun. I can also connect to it from theserver explorer in visual studio.net. I turned off thefirewall. I tried connecting with the same asp.net code from adifferent computer and still no luck. I've triple-double-checkedthe connectionstring. It's the same credentials I'm using forquery analyzer and server explorer, which both work fine. Anytroubleshooting tips would be GREATLY appreciated.

Thank you.What error message are you receiving?|||The problem ended up being with the version of .net I was using. I hadinstalled 1.1 initially, but someone installed commerce server 2002 andit installed .net 1.0 on top of that, which messed everything up. I reinstalled windows 2003 and then reinstalled .net 1.1, and all isgood.

Tuesday, February 14, 2012

Cant connect to remote SQL Server from my ASP.NET 2.0

I’m going nuts and need some help with my ASP.NET 2.0 application which has trouble talking to a remote SQL Server 2000. First, before I describe my problem let me say that everything works perfectly on my XP development workstation when I point to the local SQL Server database. Screens load fine, saves and edits all work perfectly.

Problem is when I connecting to SQL Server on a remote windows 2003 server I get

Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection.

Now, I’ve researched this error and have successfully made the following changes to the remote windows 2003 server where the database resides:

1) Added logins for “ASPNET”, “NT AUTHORITY\NETWORK SERVICE”, and “IIS_WPG”. The reason I added NT AUTHORITY is because we plan on deploying this web site to the same windows 2003 server and I understand that IIS6 (on this server) has ASP.NET running as NT AUTHORITY acct.

2) For all the logins above I’ve added them as users to the database and given dbo role.

I still get same login for user null error when attempting to connect from my XP workstation.

Can anyone help?

Hi,

You need to authenticate against the remote SQL server. Do that in your connectionstrong.

Check www.connectionstrings.com

Regards

|||

Thanks, I'm still getting error. I also want to state I am using windows authentication for this web application, and my understanding is ASP.NET is running as NT AUTHORITY (if windows 2003 and IIS 6) or ASPNET(if XP ) is this a correct assumption?My web.config is set to windows authentication.

I looked at connectionstrings.com as you suggested. This is the connection stringI auto created (it seems very consistent w/ examples on connectionstrings.com) using VisualStudio by dragging a table onto a form from the remote server "TESTSERVER" and using the Configure Data Source dialog which creates the connection string automatically. The SQL Database on TESTSERVER is set to mixed mode for both SQL and Windows authentication. Here is the string, do you see any issues?

Data Source=TESTSERVER;Initial Catalog=CompanyDB1;Integrated Security=True.

I get the same error :Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection.

Do you have any ideas on what I'm doing wrong? Why is user null? Should the user be ASPNET or NT AUTHORITY coming from my XP based web server?

|||Where is the SQL server located in?|||

The SQL Server 2000 database is located remotely on machine called TESTSERVER. This is what is in the connection string

(PS - When I want to point locally to my machine "PUU304" I use this connection string which works fine on my machine

connectionString="Data Source=PUU304;Initial Catalog=JBLocalDatabase;Integrated Security=True")

|||Well, using windows authentication for your winxp login is not working. Try to create a user/pass for your database on the remote server|||check the permission of your database|||NT AUTHORITY has dbo rights in the database. Is this the permission you are referring to?

Friday, February 10, 2012

Cant connect to any database not owned by servername\ASPNET

I'm developing an intranet application and am using the Express versions of VWD and SQL Server 2005 for initial development before obtaining full licensed versions.

Database connections work fine when testing from within VWD but when testing from browser, unless the database owner is the IIS servername\ASPNET, there are various errors depending on the specific connection settings, i.e.

Login failed for user ''. The user is not associated with a trusted SQL Server connection.-

Receive this error when a GridView is connected to a remote SSE db.

--

SELECT permission denied on object 'Table_1', database 'TEST', schema 'dbo'.

Receive this error when GridView is connected to local SSE db not owned by servername\ASPNET.

--

Failed to generate a user instance of SQL Server due to a failure in starting the process for the user instance. The connection will be closed.

This happens when using any control that is connected to SSE db created in VWD and stored in App_Data folder (owner is the user logon name)

--

Any help or ideas would be appreciated. I want to have all local data stored in App_Data folder.

Thank you.

You need to set SQL Server to use both Windows and SQL Server, that is covered below. Post again if you still need help.

http://msdn2.microsoft.com/en-us/library/ms188670.aspx

Can't connect from ASP.Net 2.0 to SQL2000 after installing SQL2005

Hey guys,
I have a web application in ASP.Net 2.0 that needs to connect to a local
SQL2000 DB. After I installed SQL2005 this web app stopped working. I get
the following inner exception:
{"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: SQL Network Interfaces, error: 26 - Error Locating
Server/Instance Specified)"}
So after unsuccessfully googling I'm at least pretty sure about the
following: My web app thinks it's talking to a SQL2005 server. That one by
default uses shared memory when local. I think SQL2000 uses TCP/IP.
Who can tell me what I have to do so that my ASP.Net 2.0 web app properly
connects to SQL2000? Among the ideas on Google there were cliconfg.exe,
using <clear /> in the <connectionStrings> area in web.config and a couple
more. But none of them worked.
Thanks a lot, ChristophI'm having a very similar error, only mine connects locally but not remotely.
I was able to change the error slightly by putting the referencing the
database by domain and db, myMachine/myDB.
If it helps I looked at my log and it gave an error of 17187 which seems to
be a file in use, full disk, or low memory. Still researching. If I find it
I'll let you know. If you find the answer would you please post it so I can
try it too?
--
---
Magic is not in the hands of the magician but in the mind of the audience.
Animadverto est verus
"Christoph Wienands" wrote:
> Hey guys,
> I have a web application in ASP.Net 2.0 that needs to connect to a local
> SQL2000 DB. After I installed SQL2005 this web app stopped working. I get
> the following inner exception:
> {"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: SQL Network Interfaces, error: 26 - Error Locating
> Server/Instance Specified)"}
> So after unsuccessfully googling I'm at least pretty sure about the
> following: My web app thinks it's talking to a SQL2005 server. That one by
> default uses shared memory when local. I think SQL2000 uses TCP/IP.
> Who can tell me what I have to do so that my ASP.Net 2.0 web app properly
> connects to SQL2000? Among the ideas on Google there were cliconfg.exe,
> using <clear /> in the <connectionStrings> area in web.config and a couple
> more. But none of them worked.
> Thanks a lot, Christoph
>
>