T-SQL View type conversion error; DROP and CREATE view makes issue vanish? - tsql

This error is really strange (SQL Server 2008 R2 (RTM). I am SELECTing from a view in some application code, and very infrequently, I get an error about an invalid data type conversion. The SQL in the view looked OK, so I scripted the view for DROP and CREATE, ran the generated script, and the issue goes away!
What could be going on here? Could it be something with statistics?
I don't have the full error message, but if it happens again, I will update my description with it.
Thanks,
Carl

You probably changed definition of underlying tables.
Once You CREATE VIEW, SQL Server keeps metadata of returning columns. If You change metadata of underlying tables, You need to recreate (DROP and CREATE VIEW) in order for view metadata to get refreshed.

Related

Crystal report shows blank data

I have crystal report that was working before database upgrade. It is only one report that doesnt work. So I would not think of a driver issue.
I am able to test this report using CRs client tools, design and then preview. The preview does not bring any data. A single parameter is used and I am sure there is data because the data is retrieved if I create a new crystal report and also verified the SQL. (So there is no question about the no data or any missing links -- its a simple view).
This cannot be a driver issue as well, as all other old reports still work.
Have also tried deleting all the field's from the report, then add a single/simple new table and preview, still no data is showing.
Are there any logs inside crystal to investigate ? have tried ODBC.logs doesnt help as doesn't say what happens inside crystal reports after retrieving the data from database.
Thanks.
Zain
I've had this problem multiple times where my report comes up with empty fields. This may not be your cause, but what fixes it for me is to make sure that the dataset/table matches is referred to by the same name everyplace. In the xxxxxxDataset.xsd file, that table that's pictured should be the same name that's used in the function GetData() As System.Data.DataSet in your .NET object that uses the stored procedure to get the data. (You may call your function something other than GetData().) So try changing the ds.Tables(0).Tablename = "xxxxxxxTable" to match what the table in the xsd file is called.

Write Conflict on azure backend

I am getting a Write Conflict Error I can't seem to get around. My database has all of the tables on Azure. The tables are all linked
I have a form that shows details about a specific course. I select the course by using a split form. On that form, I have a subform that shows the languages that course is being translated into.
Double-clicking on a specific field on the form displays another form with the details of that language's translation work.
The really puzzling issue is that I don't get the Write Conflict on all records. It occurs only on recently added translation records. I'm suspicious that there is something in those records that is causing the problem, but it isn't missing or invalid data.
I tried converting the table to a local table, and then I don't get any errors. I posted the problem to the MS Access community, and they sent me here.
Any ideas of how to fix it?
Thanks,
Merrikay

Crystal Reports cannot map to new database server

I have performed this process numerous times with other Reports but this one Report is not working as it should.
Essentially, I am trying to point a report at a new server where the stored procedure is EXACTLY the same as on the previous server. I am using the Verify Database functionality to do this. But when I point at the new server and enter parameters, CR prompts me to re-map the fields. This would be only slightly annoying if the Map Fields window actually displayed the returned columns from the new server.
But, as you can see from the image, even with the 'Match type' unchecked, no columns from the stored procedure display to be mapped. I have clicked on every field in the report but none of them show any columns to map to.
I have also tried changing the Database Location first before trying to verify, but that doesn't make any difference.
Has anybody else seen this? Is there any sort of workaround?
​I found my solution. Kinda dumb, really.
My stored procedure calls another stored procedure. I commented that call out and tried to Verify the Database and it worked.
Apparently Crystal Reports doesn't handle procedures that call other procedures very well when trying to map fields.

Get Error when Save modifed record using Light Switch on Azure

I am using Light switch on Azure.
After I modified a column in a record when I click the Save button I got
"Store update, insert, or delete statement affected an unexpected number of rows(0). Entties may have been modified or deleted since entities were loaded, Refresh ObjectStateManager entries.
I use VS 2012 on my dev machine debug this light switch app. it works fine and no errors when I modify the save column on same records then save it.
Is anybody in this forum has idea what could cause this? and how should I work around it?
I suspect the azure machine don't have the same version of EF with my dev machine. but in the Light switch project both client and server reference I could not find the EF is referenced there. So I don't know how I can bring the EF dll on my machine up to Azure machine.
Anybody could give me some suggestion on this?
Thanks
Chris
Usually it's a side effect of Optimistic Concurrency. This article can give you the idea of it in Lightswitch:
LightSwitch 2012 Concurrency Enhancements
When it's working on dev machine and it's not working on Azure, I guess something is not right in your production database.
you can also take a look at Entity framework: affected an unexpected number of rows(0)
Having Instead of insert/update triggers, sometimes SQL server does not report back an IdentityScope for each new inserted/updated row. Therefore EF can not realize the number of affected rows.
Normally, any insert/update into a table with identity column are immediately followed by a select of the scope_identity() to populate the associated value in the Entity Framework. The instead of trigger causes this second step to be missed, which leads to the 0 rows inserted error.
You can change your trigger to be either before or after insert or tweak your trigger by adding following line at the end of it:
select [Id] from [dbo].[TableXXX] where ##ROWCOUNT > 0 and [Id] = scope_identity()
Find more details in this or this thread.

Crystal Reports - Failed to open a rowset

What can be done to resolve the exception:
CrystalDecisions.CrystalReports.Engine.InternalException: Failed to open a rowset.
This is a generic error in Crystal Reports whenever the report query fails. There can be a number of causes. If your report was targeted to a specific database and then the database was changed without updated the report, this can cause it. It can also be caused by something in the query itself failing, such as if the report is based on a stored procedure that doesn't exist on the database against which the report is running. Try verifying the database for the report.
As said this is a generic error, and like all such errors it's a very frustrating one. The problem is that VS 2003 has no preview option for crystal reports so it's hard to track down the source of the problem. So best way to solve this is to create a blank project in vs 2005 or later, import the crystal report, and run preview. You will get a more specific error then.
I had the same issue, and received this error message:
One ore more fields could not be found in the result set. Use Verify Database to update the report.
Error in File filename {9FEE6406-1613-409A-B9BD-C5FDA24E3DEE}.rpt:
The rowset column could not be found.
I was using a stored procedure to collect data for the report, and sure enough I was passing an invalid parameter for the SP. Double check the type and value of the parameters if you are using a SP to populate the report data.
Good luck!
I have also gone through same error with report having sub reports. Issue resolved as i switch to each sub report and make it verify again with database/tables/views.
This is caused by some discrepancy in your relations, like opposite left joins or something similar. CR has also the bad habit to create 'default' links each time you modify the list of tables and views needed for the report. It can even sometimes automatically create recursive links that might not be viewable 'at once' in the relations screen.
If you cannot find which relation(s) is causing the trouble (sometimes it is not so obvious), you'll have to make some trial & errors test by adding/removing tables from your report.
Every time you add a new table in crystal it adds its own links on already linked tables, some times it even links the 2 fields from the same table.
Make sure you know your links in order to go through after you add a table and scroll all tables to see for any links create from to the same table
I received :
CrystalDecisions.CrystalReports.Engine.InternalException was unhandled
Message=The Report Application Server failed
Google brought me here. For those that have similar problems.
For the record: I had a byte[] array with an image and removed the log from the report and the error stopped. I now have to figure out what I have done wrong with the logo.
I had this problem - we use SQL logins for our security (not integrated / DSN connections)
By granting execute permissions to the user for my stored procedure I fixed the problem.
Really, really couldn't hate Crystal more for their exception masking - let this be a lesson to all programmers;
Try
'your code here
Catch
Throw new exception("Hey, here's a really friendly but completely useless error message")
End Try
will result in pain for future developers - DON'T DO IT!
When you verify your database it might tell you that it is up to date, in that case you have two more options to check for:
a) Refreshing the report (a lightning-shaped icon), if you have a problem with a field, such as a SQL Field, it will give you the error and then show you the edit window for the field.
b) Running the query directly on SQL, if there is a problem with the query itself you will also get this message in Crystal but SQL will tell you exactly what went wrong.
Check Changing Crystal Report Database logon information at runtime in VS2005 for help.
Important line in it is:
table.Location = Database & ".dbo." & table.Name
For me, the problem was fixed when I logged of and logged back to the SQL server that the report was connecting to
In your store procedure If you are using
SET NOCOUNT ON;
Then just remove this
--SET NOCOUNT ON;
Now verify your report database, build & run your solution.