Showing posts with label sitting. Show all posts
Showing posts with label sitting. Show all posts

Wednesday, March 21, 2012

promblems connecting to db across a network

Hello,

I've built an application using c#, visual studio 2005 and sql server 2000. The database is sitting on another machine on the network.

When I test the application from visual studio, it all works fine - no problems connecting to the database etc.

However, If I publish the website and move it to the same server as the database and set up the site and users through IIS etc, I get the following error

Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.

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 'NT AUTHORITY\NETWORK SERVICE'.

my connection string is

<connectionStrings>

<addname="cashinsConnectionString"connectionString="Data Source=Londevs;Initial Catalog=cashins;User ID=Cash; Password=Cash123;"

providerName="System.Data.SqlClient" />

</connectionStrings>

Anyone have any ideas why this is happening?

Thanks

fogofogo:

Login failed for user 'NT AUTHORITY\NETWORK SERVICE

You are trying to connect to the database with the above account which doesn't have the necessary permissions to connect.

|||

Thanks for your reply.

So do I need to set these permissions on the database or on the server where the database is sitting?

|||

actually - this is strange. I've just put together a smaller application with the EXACT same connection string as above, and it worked fine.

how could that be??Confused

|||

It's most likely a problem with your web.config file (possibly it's doing some impersonation or windows authentication) rather than just the connection string. Check both web.config files to see what you are doing differently.

|||

Thanks.

I compared them both using winmerge and they are both the same.

here my config file

12<!--3 Note: As an alternative to hand editing this file you can use the4 web admin tool to configure settings for your application. Use5 the Website->Asp.Net Configuration option in Visual Studio.6 A full list of settings and comments can be found in7 machine.config.comments usually located in8 \Windows\Microsoft.Net\Framework\v2.x\Config9-->10<configuration>11<appSettings/>12<connectionStrings>1314 <add name="cashinsConnectionString" connectionString="Data Source=servername;Initial Catalog=databasename;User ID=Cash; Password=Cash123;" providerName="System.Data.SqlClient"/>15 </connectionStrings>16 <system.web>17<!--18 Set compilation debug="true" to insert debugging19 symbols into the compiled page. Because this20 affects performance, set this value to true only21 during development.22 -->23<compilation debug="true"/>24<!--25 The <authentication> section enables configuration26 of the security authentication mode used by27 ASP.NET to identify an incoming user.28 -->29<authentication mode="Forms"/>3031<!--32 The <customErrors> section enables configuration33 of what to do if/when an unhandled error occurs34 during the execution of a request. Specifically,35 it enables developers to configure html error pages36 to be displayed in place of a error stack trace.3738 <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">39 <error statusCode="403" redirect="NoAccess.htm" />40 <error statusCode="404" redirect="FileNotFound.htm" />41 </customErrors>42 -->43</system.web>44</configuration>

all looks ok right?

I also pass the connection through...

1private static String connstring = ConfigurationManager.ConnectionStrings["cashinsConnectionString"].ConnectionString;2private static SqlConnection conn =new SqlConnection(connstring);

so I can access the connection from a .cs file that holds my classes and methods etc. Could that be the source of the problem?

Thanks

|||

Hi,

From your description, it seems that you application can connect to your database while lunched from Visual Studio but failed when lunched in IIS, right?

You can try the following steps to check if "AUTHORITY\NETWORK SERVICE" has been permitted to visit the database.

1. Open your Enterprise Manager and open the security node in your local sql server.
2. Click on "Logins", try to see if "AUTHORITY\NETWORK SERVICE" appeared in that list, if not, create the user and assign the corresponding server roles.

Thanks.

|||

Cool! thanks

Tuesday, March 20, 2012

Progress

I have some SP's I run once a month and each SP takes a few mins to run and when I batch em together in one shot, I hate sitting there waiting for them to finish
whats the easiest way to report back the status of the exec?

Ex:
Set NoCount ON
EXEC StatesUpdateZipTableUpdate 'AE'
EXEC StatesUpdateZipTableUpdate 'AK'
EXEC StatesUpdateZipTableUpdate 'AL'
EXEC StatesUpdateZipTableUpdate 'AP'
EXEC StatesUpdateZipTableUpdate 'AR'
EXEC StatesUpdateZipTableUpdate 'AZ'

How would I get it to report the results after each Exec?
In otherwords Id like to create a progress bar......

Just for Query Analyzer..... no bells and whistles

You can add RAISERROR messages WITH NOWAIT option after each EXEC statement to send a message immediately to the client. If you don't use NOWAIT option the message might still be in the server output buffer and it will not get flushed & sent to client before it is full. Apart from this, there is no way to get a progress bar or progress information for the execution. Ex:

Set NoCount ON
EXEC StatesUpdateZipTableUpdate 'AE'
raiserror('After exec #1...', 0, 1) with nowait

EXEC StatesUpdateZipTableUpdate 'AK'
raiserror('After exec #2...', 0, 1) with nowait

EXEC StatesUpdateZipTableUpdate 'AL'
raiserror('After exec #3...', 0, 1) with nowait

EXEC StatesUpdateZipTableUpdate 'AP'
raiserror('After exec #4...', 0, 1) with nowait

EXEC StatesUpdateZipTableUpdate 'AR'
raiserror('After exec #5...', 0, 1) with nowait

EXEC StatesUpdateZipTableUpdate 'AZ'

raiserror('After exec #6...', 0, 1) with nowait

|||

Thats what I needed, infact its what I did before but stuck it at the end of the SP itself.. sometimes It just takes a second set of eyes.....

Thanks!

|||Bummer, didnt work........ Still get all the results at one time|||That could just mean that the SP execution completes fast so the difference in the messages output is not noticeable.|||

set ANSI_NULLS ON

set QUOTED_IDENTIFIER ON

go

ALTER PROCEDURE [dbo].[StatesUpdateZipTableUpdate]

(

@.State Varchar(2)

)

AS

Set NoCount ON

Set Transaction Isolation Level read committed

Declare @.RID Int,

@.RowVal Int,

@.UpdatedRows Int,

@.X_Error Varchar(50)

Set @.UpdatedRows = 0

Select

RecordID = Identity(int,1,1),

Zip_ZipCode,

Zip_SignatureCode

Into #Temp

from tempstatezip

where State = @.State

exec ('Delete From tax...' + @.State + 'ZIP' )

While (Select Count(*) from #temp)>0

Begin

Set @.rowVal = (Select top 1 RecordID from #Temp)

set @.RID = (Select Max(RecordID) from #Temp)

exec ('

Insert INTO tax...' + @.State + 'ZIP

(RecordID,

Zip_ZipCode,

Zip_SignatureCode)

Select

RecordID + ' + @.RID + ',

Zip_ZipCode,

Zip_SignatureCode

From #Temp

Where ' + @.RowVal + ' = RecordID')

Set @.UpdatedRows = @.UpdatedRows + 1

Set @.X_Error = convert(Varchar(5), @.UpdatedRows) + ' Rows have been updated for ' + @.State

Delete From #Temp where @.RowVal = RecordID

END

raiserror (@.X_Error, 0, 1) with nowait

Set NoCount Off

DROP TABLE #Temp

Theres about 78 State I run with each one having an average of 5000 rows that get updated.Each state actually takes about 45 mins to run +/-

Its slow as the linked server is an Access Db......

And youre probably thinking why am I doing it this way? well its the only way I can get my proprietary software to take the update. Theres some unique Identifiers that get generated in the software program upon import of the access db....

Got any ideas on improving this?

Wednesday, March 7, 2012

Programmatically chosing an image in table

So we've got a report, and some external images (i.e. sitting on the
server's HD). I don't really want to put them in the SQL 2000 database if I
don't have to (mainly because I don't know how), but I want one column of
the report to be one of 5 images, depending on the value a column in the
table. If I embed the images, I can't see a way to chose one of the images
in the table; I can just make all the column the same. Or can I just code
the HTML line manually... Have to try that, I guess. Any other ideas?
If it helps, the report is a table of calls our customers have submitted,
and the image displays a bug, dollar sign, plus sign, script page or
question mark depending on whether the call is a bug, customization, feature
request, script request, or 2nd level support question.
ClintWe have created some "dashboard" like reports that have different icons
(for data audits). Obviously this might not be the best method for
everyone, but it works for us. We have folder structure like below:
Production
Images
Audit Reports
User Reports
Manager Reports
We implement our images through relative URLs. We put the images we
need inside the Images folder (this allows for reuse). In the report,
I insert an image from a URL (When using the wizard, I use a random
image url). Once the wizard is finished, I change the Value property
to be the URL like the following =iif(condition,
""../../Images/StoplightSingleRed.gif",
"../../Images/StoplightSingleGreen.gif")
You could also just use an absolute path (we used the relative in case
we changed server names).
Hopefully this solution will work for you.
Regards,
Dan|||Maybe I wasn't as clear as I could've been. The folder structure above
is what we have implemented in the Report Manager. We then uploaded
the files to the report manager inside the image folder.|||Dan,
Worked like a hot darn! Thanks. FYI, the solution was to drop in an image,
link it to one of my existing images, just for giggles. Then I modified the
Value section on the Properties of that object to:
=Switch(Fields!PDPType.Value="Bug", "http://localhost/images/bug.gif",
Fields!PDPType.Value="Customization Request",
"http://localhost/images/customization.gif", Fields!PDPType.Value="New
Feature/Enhancement", "http://localhost/images/enhancement.gif",
Fields!PDPType.Value="Script Request", "http://localhost/images/script.gif",
Fields!PDPType.Value="Support Request", http://localhost/images/support.GIF)
I might have to tweak and tune my file locations, and I've got to re-size
all my images so they're consistent (darn graphics people...). But I didn't
know you could put a conditional value in the image Value section. That's
the piece I was missing. The documentation on a lot of this stuff seems to
be rather lacking. It seems to cover the very minimum amount.
Clint
"Dan" <daniel.lenz@.qg.com> wrote in message
news:1141321207.081912.144230@.z34g2000cwc.googlegroups.com...
> Maybe I wasn't as clear as I could've been. The folder structure above
> is what we have implemented in the Report Manager. We then uploaded
> the files to the report manager inside the image folder.
>|||Ok, so this started working. But now I've thrown sorting on the report, and
as soon as I sort, the images get lost. If I look at the source for the
page, the image tag comes up like:
<IMG class="r1" src="http://pics.10026.com/?src="/>
, whereas the pre-sorted image tag looks like:
<IMG class="r1"
SRC="/Reports/Reserved.ReportViewerWebControl.axd?ReportSession=cc3iww2i5xcx2jea3gi0ia45&ControlID=33d1f91a-7bc7-4876-a195-7210eae11061&Culture=1033&UICulture=9&ReportStack=1&OpType=ReportImage&StreamID=56"/>
All this works fine in the Preview in VS2005 (the sorting, that is). Any
ideas? I'm beginning to think I should have imported the images into SQL...
Clint
"Clint" <nobody@.nowhere.non> wrote in message
news:%23zeX2MjPGHA.3728@.tk2msftngp13.phx.gbl...
> Dan,
> Worked like a hot darn! Thanks. FYI, the solution was to drop in an
> image, link it to one of my existing images, just for giggles. Then I
> modified the Value section on the Properties of that object to:
> =Switch(Fields!PDPType.Value="Bug", "http://localhost/images/bug.gif",
> Fields!PDPType.Value="Customization Request",
> "http://localhost/images/customization.gif", Fields!PDPType.Value="New
> Feature/Enhancement", "http://localhost/images/enhancement.gif",
> Fields!PDPType.Value="Script Request",
> "http://localhost/images/script.gif", Fields!PDPType.Value="Support
> Request", http://localhost/images/support.GIF)
> I might have to tweak and tune my file locations, and I've got to re-size
> all my images so they're consistent (darn graphics people...). But I
> didn't know you could put a conditional value in the image Value section.
> That's the piece I was missing. The documentation on a lot of this stuff
> seems to be rather lacking. It seems to cover the very minimum amount.
> Clint
> "Dan" <daniel.lenz@.qg.com> wrote in message
> news:1141321207.081912.144230@.z34g2000cwc.googlegroups.com...
>> Maybe I wasn't as clear as I could've been. The folder structure above
>> is what we have implemented in the Report Manager. We then uploaded
>> the files to the report manager inside the image folder.
>|||Ahhh, sweetness happens! We happened to have a MS rep here today who
specializes in ReportServer, and I mentioned my problem. He suggested
embedding the images, changing the source to Embedded, and then changing the
Value statement to:
=Switch(Fields!PDPType.Value="Bug", "Bug",
Fields!PDPType.Value="Customization Request", "Customization",
Fields!PDPType.Value="New Feature/Enhancement", "Enhancement",
Fields!PDPType.Value="Script Request", "Script",
Fields!PDPType.Value="Support Request", "Support")
Besides working properly with the sort, it has be added benefit of
distributing the images with the report. Now if I could only get the
RowNumber function to work!
Clint
"Clint" <nobody@.nowhere.non> wrote in message
news:exU7IhwPGHA.140@.TK2MSFTNGP12.phx.gbl...
> Ok, so this started working. But now I've thrown sorting on the report,
> and as soon as I sort, the images get lost. If I look at the source for
> the page, the image tag comes up like:
> <IMG class="r1" src="http://pics.10026.com/?src="/>
> , whereas the pre-sorted image tag looks like:
> <IMG class="r1"
> src="http://pics.10026.com/?src=/Reports/Reserved.ReportViewerWebControl.axd?ReportSession=cc3iww2i5xcx2jea3gi0ia45&ControlID=33d1f91a-7bc7-4876-a195-7210eae11061&Culture=1033&UICulture=9&ReportStack=1&OpType=ReportImage&StreamID=56"/>
> All this works fine in the Preview in VS2005 (the sorting, that is). Any
> ideas? I'm beginning to think I should have imported the images into
> SQL...
> Clint
> "Clint" <nobody@.nowhere.non> wrote in message
> news:%23zeX2MjPGHA.3728@.tk2msftngp13.phx.gbl...
>> Dan,
>> Worked like a hot darn! Thanks. FYI, the solution was to drop in an
>> image, link it to one of my existing images, just for giggles. Then I
>> modified the Value section on the Properties of that object to:
>> =Switch(Fields!PDPType.Value="Bug", "http://localhost/images/bug.gif",
>> Fields!PDPType.Value="Customization Request",
>> "http://localhost/images/customization.gif", Fields!PDPType.Value="New
>> Feature/Enhancement", "http://localhost/images/enhancement.gif",
>> Fields!PDPType.Value="Script Request",
>> "http://localhost/images/script.gif", Fields!PDPType.Value="Support
>> Request", http://localhost/images/support.GIF)
>> I might have to tweak and tune my file locations, and I've got to re-size
>> all my images so they're consistent (darn graphics people...). But I
>> didn't know you could put a conditional value in the image Value section.
>> That's the piece I was missing. The documentation on a lot of this stuff
>> seems to be rather lacking. It seems to cover the very minimum amount.
>> Clint
>> "Dan" <daniel.lenz@.qg.com> wrote in message
>> news:1141321207.081912.144230@.z34g2000cwc.googlegroups.com...
>> Maybe I wasn't as clear as I could've been. The folder structure above
>> is what we have implemented in the Report Manager. We then uploaded
>> the files to the report manager inside the image folder.
>>
>