Showing posts with label writing. Show all posts
Showing posts with label writing. Show all posts

Wednesday, March 28, 2012

problems with sqlreader

Hi everyone,

I am writing a simple login application in asp 2.0. I have spent quite a little bit of time of this error so any help would be greatly appreciated.

Here is the code i am using.

Dim cnAs SqlConnection

Dim cmdAs SqlCommand

Dim sqlAsString ="select password from attendant where " & _

" ((username = @.username) and (password = @.password)"

cn =

New SqlConnection("Data Source=z-davis\sqlexpress;Initial Catalog=Trainingdb;Integrated Security=True")' cn = New SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings("TrainingdbConnectionString").ToString)

'I have tried both connection strings and get the same error.

cmd =New SqlCommand(sql, cn)

cmd.Parameters.Add(

"@.username", SqlDbType.VarChar, 50)

cmd.Parameters(

"@.username").Value = txtuser.Text

cmd.Parameters.Add(

"@.password", SqlDbType.VarChar, 50)

cmd.Parameters(

"@.password").Value = txtpass.Text

cn.Open()

Dim myreaderAs SqlDataReader

myreader = cmd.ExecuteReader(CommandBehavior.CloseConnection)

'The line above is where i get the error.

If myreader.Read()Then

FormsAuthentication.RedirectFromLoginPage(txtuser.Text,

False)Else

Response.Write(

"Try again")

After stepping through the code the error stops on this line:

myreader = cmd.executereader(commandbehavior.closeconnection)

The error that is generated is: Incorrect syntax near ')'

Any help would be greatly appreciated or any other code snippets

Thanks,

notrosh

In this line you have 3 open parentheses and only 2 close parentheses.

Dim sqlAsString ="select password from attendant where " & _

" ((username = @.username) and (password = @.password)"


Remove the first open parenthesis and you will have better luck.

|||

Thanks,

Sometimes you need an outside eye to see an error that simple.

zach davis

|||Or you need to have made that same sort of error a few dozen timesWink [;)]

I've learrned to count my parentheses using my fingers. Working left to right in my SQL statement, I put up a finger each time I open one, and put down a finger each time I close one. When I get to the last character, if I have any fingers sticking up, I know I have a problem. Pretty silly approach, but it works for me.

Wednesday, March 7, 2012

problems with both file share subscriptions

I am having also problems with both email/file share subscriptions. The
Report
Manager displays the following error: Failure writing file Company Sales :
The Report Server has encountered a configuration error; more details in the
log files
This is the info from the logfile.
Reporting services and sql2000 DB are running on the same machine:
test-piv1900 (a win 2003) server
the service is running under the account: "Network Service".
With the subscription I provided the credentials from the local
Administrator of the "test-piv1900" server.
the fileshare I use is \\test-piv1900\test , I granted everyone full control
to it and additionaly granted Network Service again full control.
The report itselfs runs correct if I access it within the reportmanager.
anyone any idea's?
ReportingServicesService!subscription!f08!07/05/2004-14:20:09::
Microsoft.ReportingServices.Diagnostics.Utilities.RSException: The Report
Server has encountered a configuration error; more details in the log
files -->
Microsoft.ReportingServices.Diagnostics.Utilities.ServerConfigurationErrorEx
ception: The Report Server has encountered a configuration error; more
details in the log files
at
Microsoft.ReportingServices.Authorization.Native.GetAuthzContextForUser(IntP
tr userSid)
at Microsoft.ReportingServices.Authorization.Native.IsAdmin(String
userName)
at
Microsoft.ReportingServices.Authorization.WindowsAuthorization.IsAdmin(Strin
g userName, IntPtr userToken)
at
Microsoft.ReportingServices.Authorization.WindowsAuthorization.CheckAccess(S
tring userName, IntPtr userToken, Byte[] secDesc, ReportOperation
requiredOperation)
at Microsoft.ReportingServices.Library.Security.CheckAccess(ItemType
catItemType, Byte[] secDesc, ReportOperation rptOper)
at
Microsoft.ReportingServices.Library.RSService._GetReportParameterDefinitionF
romCatalog(CatalogItemContext reportContext, String historyID, Boolean
forRendering, Guid& reportID, Int32& executionOption, String&
savedParametersXml, ReportSnapshot& compiledDefinition, ReportSnapshot&
snapshotData, Guid& linkID, DateTime& historyDate)
at
Microsoft.ReportingServices.Library.RSService._GetReportParameters(String
report, String historyID, Boolean forRendering, NameValueCollection values,
DatasourceCredentialsCollection credentials)
at
Microsoft.ReportingServices.Library.RSService.RenderAsLiveOrSnapshot(Catalog
ItemContext reportContext, ClientRequest session, Warning[]& warnings,
ParameterInfoCollection& effectiveParameters)
at
Microsoft.ReportingServices.Library.RSService.RenderFirst(CatalogItemContext
reportContext, ClientRequest session, Warning[]& warnings,
ParameterInfoCollection& effectiveParameters, String[]&
secondaryStreamNames)
at
Microsoft.ReportingServices.Library.RenderFirstCancelableStep.Execute()
at
Microsoft.ReportingServices.Diagnostics.CancelablePhaseBase.ExecuteWrapper()
-- End of inner exception stack trace --
at
Microsoft.ReportingServices.Diagnostics.CancelablePhaseBase.ExecuteWrapper()
at
Microsoft.ReportingServices.Library.RenderFirstCancelableStep.RenderFirst(RS
Service rs, CatalogItemContext reportContext, ClientRequest session,
JobTypeEnum type, Warning[]& warnings, ParameterInfoCollection&
effectiveParameters, String[]& secondaryStreamNames)
at Microsoft.ReportingServices.Library.ReportImpl.Render(String
renderFormat, String deviceInfo)
at
Microsoft.ReportingServices.FileShareDeliveryProvider.FileShareProvider.Save
Report(Notification notification, SubscriptionData data)
at
Microsoft.ReportingServices.FileShareDeliveryProvider.FileShareProvider.Deli
ver(Notification notification)
thx for any responsesHi all,
When I log on the reportserver itself and use the Local Administrator
account to create the fileshare.
It works.
When I use my domain Credentials it fails even if I tell the fileshare to
use the Local Administrator credentials it only works if I accessed the
reportmanager with the Local Administrator credentials.
I still can't mail any reports ...
same error
and of course i ran servicepack 1.
these are my mailing settings.
is there maybe somthing wrong with?
"Stijn Lambrechts" <stijn.lambrechts@.pandora.be> wrote in message
news:eGC2P4oYEHA.716@.TK2MSFTNGP11.phx.gbl...
> I am having also problems with both email/file share subscriptions. The
> Report
> Manager displays the following error: Failure writing file Company Sales :
> The Report Server has encountered a configuration error; more details in
the
> log files
> This is the info from the logfile.
> Reporting services and sql2000 DB are running on the same machine:
> test-piv1900 (a win 2003) server
> the service is running under the account: "Network Service".
> With the subscription I provided the credentials from the local
> Administrator of the "test-piv1900" server.
> the fileshare I use is \\test-piv1900\test , I granted everyone full
control
> to it and additionaly granted Network Service again full control.
> The report itselfs runs correct if I access it within the reportmanager.
> anyone any idea's?
> ReportingServicesService!subscription!f08!07/05/2004-14:20:09::
> Microsoft.ReportingServices.Diagnostics.Utilities.RSException: The Report
> Server has encountered a configuration error; more details in the log
> files -->
>
Microsoft.ReportingServices.Diagnostics.Utilities.ServerConfigurationErrorEx
> ception: The Report Server has encountered a configuration error; more
> details in the log files
> at
>
Microsoft.ReportingServices.Authorization.Native.GetAuthzContextForUser(IntP
> tr userSid)
> at Microsoft.ReportingServices.Authorization.Native.IsAdmin(String
> userName)
> at
>
Microsoft.ReportingServices.Authorization.WindowsAuthorization.IsAdmin(Strin
> g userName, IntPtr userToken)
> at
>
Microsoft.ReportingServices.Authorization.WindowsAuthorization.CheckAccess(S
> tring userName, IntPtr userToken, Byte[] secDesc, ReportOperation
> requiredOperation)
> at Microsoft.ReportingServices.Library.Security.CheckAccess(ItemType
> catItemType, Byte[] secDesc, ReportOperation rptOper)
> at
>
Microsoft.ReportingServices.Library.RSService._GetReportParameterDefinitionF
> romCatalog(CatalogItemContext reportContext, String historyID, Boolean
> forRendering, Guid& reportID, Int32& executionOption, String&
> savedParametersXml, ReportSnapshot& compiledDefinition, ReportSnapshot&
> snapshotData, Guid& linkID, DateTime& historyDate)
> at
> Microsoft.ReportingServices.Library.RSService._GetReportParameters(String
> report, String historyID, Boolean forRendering, NameValueCollection
values,
> DatasourceCredentialsCollection credentials)
> at
>
Microsoft.ReportingServices.Library.RSService.RenderAsLiveOrSnapshot(Catalog
> ItemContext reportContext, ClientRequest session, Warning[]& warnings,
> ParameterInfoCollection& effectiveParameters)
> at
>
Microsoft.ReportingServices.Library.RSService.RenderFirst(CatalogItemContext
> reportContext, ClientRequest session, Warning[]& warnings,
> ParameterInfoCollection& effectiveParameters, String[]&
> secondaryStreamNames)
> at
> Microsoft.ReportingServices.Library.RenderFirstCancelableStep.Execute()
> at
>
Microsoft.ReportingServices.Diagnostics.CancelablePhaseBase.ExecuteWrapper()
> -- End of inner exception stack trace --
> at
>
Microsoft.ReportingServices.Diagnostics.CancelablePhaseBase.ExecuteWrapper()
> at
>
Microsoft.ReportingServices.Library.RenderFirstCancelableStep.RenderFirst(RS
> Service rs, CatalogItemContext reportContext, ClientRequest session,
> JobTypeEnum type, Warning[]& warnings, ParameterInfoCollection&
> effectiveParameters, String[]& secondaryStreamNames)
> at Microsoft.ReportingServices.Library.ReportImpl.Render(String
> renderFormat, String deviceInfo)
> at
>
Microsoft.ReportingServices.FileShareDeliveryProvider.FileShareProvider.Save
> Report(Notification notification, SubscriptionData data)
> at
>
Microsoft.ReportingServices.FileShareDeliveryProvider.FileShareProvider.Deli
> ver(Notification notification)
> thx for any responses
>

Saturday, February 25, 2012

Problems with accessing database remotely

I'm writing an web app in VS2005.

I've created a product.mdf database through VS2005's Server Explorer (to my knowledge, I'm not using Sql Express). (Side question. The .mdf files are a stand alone xml structure used as a database, correct?).

When I execute locally, everything works great. But when I moved my code to where it is being hosted (remote computer). It's throwing the following error:

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)

This is my connection string:

<addname="MyConnectionString1"connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Product.mdf;Integrated Security=True;User Instance=True"providerName="System.Data.SqlClient"/>

What is my problem?

There is no SQL Server 2005 Express running on the remote server.

Jos

|||

Actually, you ARE using SQL Express. The Visual Studio environment does a great job in hiding this - but behind the scenes a SQL Express database engine is running on your local machine (you can see it in the Services.msc explorer). Your web application is using the web.config connection string tofind this SQL Express database.

As the previous reply says, the error message is due to the application trying to find a SQL Express database engine running on the remote computer and serving a database called Product.mdf.

The solution to your problem may be to install SQL Express on the remote computer. You will then need to copy (attach) the Product.mdf database to the remote database server.

However, if your "remote computer" is actually a hosting provider - they may not (and most don't) support SQL Express - and may insist that you use SQL Server Enterprise instead, which is a far more robust option anyway.

|||

Why I got the error message?

The error message you got was due to the using of SQL Express in your local (development) machine.

Ok, how to solve this issue?

It is easy. Eiteher use SQL Express on your production (e.g. hosting server) [NOT Recommended] or do the following:

Attach your .mdf file to a database (e.g. new database) in the sql server of the hosting company.
Change your ConnectionString to be as following:

<add name="MyConnectionString1" connectionString="Server=YourSqlServerName;Database=MyDatabase;Integrated Security=True;" providerName="System.Data.SqlClient"/>

YourSqlServerName: Type the name of the sql server as provided by the hosting company.

MyDatabase: The database you are using which reside in the hosting company sql server.

Note: The above ConnectionString is used with "Windows Authentication", for the "Mixed Mode" use the following ConnectionString:

<add name="MyConnectionString1" connectionString="Server=YourSqlServerName;Database=MyDatabase;User ID=MyUserID; Password:MyStrongPassword"providerName="System.Data.SqlClient"/>