LINQ to SQL and date format incorrect - linq-to-sql

I have my application working fully on my development machine and storing data all okay on a SQL 2008 database, how every when I deploy the application to my server, which is running SQL 2008, and the model is stored in the database the date fields do not accept an English date format.
e.g.
13/08/2009
fails

Sounds like you are running with a different culture on the machine you have deployed to, where that date format (US) is not valid. First place to look is the culture set in the Windows Control panel.
If you can't change the machine settings in ASP.NET you can do this through the Web.config file.
CodeProject has an article describing one way to do this for Windows forms.

Related

access shared data source by report designer, created in SSRS web portal

I recently started learning SSRS; I created a data source over SSRS web-portal; I am wandering whether such a data source can be accessed from /by Report Designer to create report and data sets.
Would anyone please help me understand the scope of such data source created in SSRS web-portal.
Thank you for giving your valuable time.
Generally you will create your shared data sources in Visual Studio/Report Designer and then publish them to the server. The end results is that you will have a data source available on the server (as it sounds like you have now).
By default data sources are not overwritten when you deploy reports, the idea is that you can have a data source on your development machine and as long as it has the exact same name on the server, when you deploy your report, it will look for the data source of the same name.
As it sounds like you created the data source directly from the web portal, you will have to recreate it on your development machine with the same name, when you deploy the report it will use the version on the server.
This also means that you can have a data source on your development machine, called dsSales for example and it might point to myTestServer\myDatabase and on the production server you could have a data source with the same name, pointing to myProductionServer\myDatabase (assuming the same tables etc exist on both) then you can test with data from the test server and when you deploy it will connect using the data source that connects to the production server.
I hope that clears it up a little.

looping through a database to show information within divs

I am just starting out in ASP.NET with previous experience in C++ and was wondering if you can help me out/point me in the right direction here.
I know how to link an Access database to visual studio's web forms however when showing the data I have found the tables to be very ugly so wanted to populate classes with the data.
In my "product details" database are; product name, price, description, rating, cost etc.
Using this information from the database I understand that my code should attempt to connect to the database server then attempt to access the specified database schema.
By giving the database any table name I hoped to return an array of all rows with all data inside it, possibly within a function called selectingData? As it loops through each row, it stores the data as an associative array which is then saved as a new array element.
I could then apply some styling...
<div style="float:left; width:50%;"> ...logic of code... </div>
<div style="clear:both;"></div>
You should use Sql Server Express 2008 or 2012, might as well use 2012. Download and install, make sure to include Sql Server Management Studio with your installation package install. You can choose server only but you want the Sql Server Management Studio tool included in your install as well.
Sql Server Management Studio will easily import your Access database and make a Sql Database of it. Right click your localhost server after you install in Sql Server Management Studio and click Import and follow wizard options, there is a source type setting for Microsoft Access database.
From here you want to use Entity Framework 5 or 6 via Visual Studio 2012 or 2013. Visual Studio 2012 or 2013 Web Express are always free and the best IDE ever. You can generate a model of your imported access database. Just create a new ASP.NET Website (go with MVC) and then right click the project and select Add -> Add New Menu Item -> EF5.x or EF 6.x DbContext Generator. This will give you the functionality you need via Linq to query tables, get result sets, manipulate those result sets and bind them to your display HTML.
You might as well do things the right way since you are getting into ASP.NET. This path is a treat and easy to learn but you will have a day or two of a learning curve ahead of you.

Is it possible to programmatically set the ProviderManifestToken for a code-first EF model?

We have an environment where each of our clients has their own database instance (with identical schemas, for all intents and purposes). We have a dashboard application where clients can login to perform CRUD operations on data in their specific database. We use a single code-first EF model for interacting with the databases. (For whatever client is being viewed, we simply pass that client's database's connection string when instantiating the DbContext.)
However, the database instances are a mix of SQL Server 2005 and 2008. (I'm pretty sure this is the root of the problem we're seeing.)
On a particular page, we've begun to see the following error occur:
The version of SQL Server in use does not support datatype 'datetime2'.
From Googling and StackOverflowing, I've come to the conclusion that it's probably due to a misconfigured ProviderManifestToken on the DbContext.
However, the error is sporadic. Based on production error logs, I can view the same client for which the error occurred and perform the same CRUD operations without getting the error.
I'm at a loss.
Is it even possible to programmatically set the ProviderManifestToken? Or maybe the default connection factory isn't properly setting it (and there's something I can do to help it along)? Or am I way off base? Any ideas?
By the way...
The entity that the error is occurring on has 2 datetime columns, both of which are nullable (and the most recent error had null and Jan 13, 2012 as its values for those fields, so I'm pretty sure that this answer about ensuring that the values are within datetime's range doesn't apply.
Well, no solution yet. But we figured out a workaround for now.
If we restart the app pool, then immediately visit the client dashboard for a 2008-backed client, EF will generate and cache a mapping based on SQL Server 2008 constraints and all 2008-backed dashboards work just fine but 2005-backed dashboards fail on writes with the datetime2 error.
However, if we restart the app pool, then immediately visit a 2005-backed client dashboard, EF will generate and cache a mapping based on SQL Server 2005 constraints (which allows the model to work with both 2005 and 2008 database instances).
So, basically, our publish process now has the extra step of immediately visiting a 2005-backed dashboard.
Thank you for posting this. I had the same problem with a console app that visited a SQL2008 DB than a SQL2005 DB and had the same problem. I switched it so it went SQL2005 first, than SQL2008 and the problem went away. I am also using EF code first.

SQL Server 2008 FILESTREAM Progress Indicator

I have a SQL Server 2008 database with a table that contains a FILESTREAM varbinary(max) column. I have set up the database server to use file streaming and everything works well. I have also created a client application using C# + Entity Framework 4.1 (Visual Studio 2010)—this too works well and I can read and write to the varbinary(max) column without any difficulty. My problem is this: for very large files it can take a while to upload/download the file data from the database. Is there a way that I can determine how much progress has been made and notify the user?
Thanks!
No because EF doesn't support filestream. Once you mapped it as varbinary(max) it is accessed in exactly same way as any other varbinary column and must be completely fetched. If you want to take advantage of advanced filestream features you must use native SQL through ADO.NET.

MS-Access front-end does not recognise dates from SQL Server

I have a SQL Server 2008 database with an Access front-end. My problem is that Access does not recognise SQL Server's dates as they are in a different format.
SQL Server-s format is YYYY-MM-DD
Access' format is DD-MM-YYYY
When the date is displayed in a text-box, it is displayed as a string (without the little calendar icon next to it).
Is there anyway I can configure my Access front-end so that it recognises SQL Server's dates?
Cheers.
If you are storing the dates in SQL server as the data type “Date” or “Date2” try changing them to “DateTime” I had this problem linking data from SQL server 2008R2 to access 97, access did not see it as a date and treated it like text
The Microsoft SQL Server Migration Assistant for Access does move the dates over as a Date format. The problem the user has encountered is with a Driver. Microsoft has a new DLL that must be put on a client workstation (or server in the case of Citrix).
Once that is done, all the dates in MS Access will work properly.
My lastest experience with Access 2010 was exactly the same as Access 2003. It required a DLL.
From there, investigate using a DNS-Less connection string.
I just ran in to this, thanks everyone for your input.
I'm also developing an Access UI for a SQL Server backend (Access 2010/SQL Server 2014) and just encountered this problem. The Date datatype takes 3 bytes of storage, and since I didn't need a time component, that's what I wanted. Personally I'm using SmallDateTime, it takes 4 bytes compared to DateTime's 8. There's also DateTime2 that takes 6-8 bytes.
I created a four field table using each of the date datatypes to experiment with input formats, I think SmallDateTime will do the trick for me.