I am writing a clickonce application in vb.net. I have sql tables linked to a Microsoft Access database, and then my application reads through the OLEDB connection.
My columns in SQL are saved as date however when linked to MS Access they convert to "text" I haven't had any issues with this until I started creating charts on my application. I need the dates on the chart to display as jan 17 feb 17 etc however no matter what formatting I use they come back as '2017-01-01' '2017-02-01'
I have tried
ChartFCR.Series(0).XValueType = DataVisualization.Charting.ChartValueType.DateTime
ChartFCR.ChartAreas(0).AxisX.LabelStyle.Format = "MMMyy"
in various forms and nothing is changing the appearance. any information or suggestion is helpful.
Thanks
The only way Access will make sense of a SQL date data type is if it is converted into 1) a datetime in SQL or 2) a date in Access.
Of course it depends on your situation, but try creating a query in Access that handles that conversion and base the chart on the query. That would give you the most control for the Access interface.
Related
I'm having trouble implementing what I feel should be a fairly basic report in SSRS (SQL Server 2014 and VS2013 Shell). I work for a company based in the UK and I want to show various data using the Maps functionality. To start with I simply want to take customer sales data and plot it over a basic UK map. To that end I have constructed a query which uses the customer postcode to obtain latitude and longitude values. I have then used STPointFromText to convert these to the Geography data type as follows:
geography::STPointFromText('POINT(' + CAST(longitude AS VARCHAR(20)) + ' ' +
CAST(latitude AS VARCHAR(20)) + ')', 4326) AS Geog
This dataset contains the sales figures, so the analytical and spatial data is all in one place (assuming I've understood this part correctly!).
When I query this data in SSMS and view the results under the Spatial tab, it looks quite promising, i.e. quite clearly plots the shape of the UK:
spatialoutput SSMS
However, when I try to represent this in SSRS, it falls apart. Using the SQL Server spatial query option as my data source, and using the query I constructed and ran in SSMS previously, I keep getting a popup window which reads:
'Unable to determine the spatial data type in the specified dataset field: Geog'
From here nothing works. I don't see any maps or any points like I did in SSRS. I've been searching for hours and not really found a solution, although I did find this on MSDN:
https://msdn.microsoft.com/en-us/library/hh272532.aspx
'You cannot use the dataset designer in Visual Studio for queries that return SQL Server spatial types. The dataset designer does not support user-defined types (UDTs), to which category the SQL Server spatial types (SqlGeometry and SqlGeography) belong.'
Various articles I have read showed people simply building a query like mine and then adding it as a dataset, after which it detected the spatial column and type straight away. Many did appear to be SQL Server 2008 R2 though. The article above implies a load of messing around with files in the GAC and the creation of a Windows Form Application, which presumably requires VS Pro and additional fiddling.
If anyone could point out where I'm going wrong it would be much appreciated!
Thanks in advance.
I have an access form with a fairly complex query displaying raw test values and the resulting test calculations on a large MS Access Form that was created in access 2007. Every once in a while my data entry guys are complaining that upon leaving and returning to their database form they see an error with text "This expression is typed incorrectly or it is too complex to be evaluated. For example, a numeric expression may contain too many complicated elements...". After this error appears every textbox is populated with the "#NAME?" error code.
I am curious if anyone has experience with this. I recently migrated the backend table from another MS Access database to SQL Server. My table has a primary key in SQL Server and also a timestamp column. Lastly, I have tried to reduce the size of the query that produces the calculations displayed on the form. On top of that not working, it previously worked within Access , so I don't see how simply moving the table to SQL server would cause the size of the query to now be too much.
Any help is appreciated, thanks.
This is a late response but I've recently experienced a similar issue and found it to be data type related.
Check if your SQL Server table's primary key data type is "bigint". If it is this may cause problems reading the data in Access. Access 2016 supports large number types but it needs to be set in Options-->Current Database-->Data Type Support Options. Note that setting large number support will prevent your Access app from working in version prior to 2016.
One suggestion, which may actually speed up the forms as well. Is to rewrite the query you are using as your bound data source for the form as a view on the SQL server.
Then link this view to your MS Access front end and use it as the bound object.
Depending on your requirements, Read/Write, and experience in SQL this may be an easy thing to do or a moderately tough thing to do.
Access is pretty greedy with the network connection so any processing you can move server side is fantastic.
I have a MS Access 2010 front end / SQL Server 2012 back end database, with a number of date fields in different tables. Sometimes I need to store the time, so I have used data types datetime or smalldatetime. However certain fields only need to store the date, so I used data type Date.
My problem is that in MS Access, my ODBC-linked table shows the Date data type fields as Text. This is then leading to problems with some dates being stored in the yyyy-dd-mm format and others in the yyyy-mm-dd format.
Is this a bug? Do I need to use smalldatetime?
Thanks for any assistance,
Jim
Had the same issue myself linking Access 2007 and SQL Server 2008.
See this question, if you look at Albert D. Kallal's comment to the first answer, it tells us that the problem is with an outdated driver connecting the front end to the back end.
If you aren't able to choose an up-to-date driver (and bear in mind that even if you can, other users of your database on different client machines may not be able to) the workaround is to use datetime data type in every case.
Just to expound on the comment given by #BiigJiim I actually had the Native client 11.0 driver already installed but as I was creating DSN-Less table connections I had to change my connection string formally to: Driver={SQL Server Native Client 11.0};
Also as an additional note, I do not believe the Date and DateTime2 data types are recommended for Microsoft Access integration. If memory serves me correctly it recommends either DateTime and SmallDateTime. I get not needing the Time in a lot of circumstances, but you can easily format it via the front end... especially within Access.
I'm currently porting a Access 2003 app to use a SQL Server 2005 back-end, and I'm having trouble with the datetime representations.
As I understand it, the default Access behavior is to use the datetime format defined on the local machine's regional settings, as do SQL-Server. Is there a way to force Access to use another default format (other than those available in the "Format" property dropdown list), something like Format = "dd/mm/yyyy"?
My problem is that a good many forms in the app have sub-forms whose data is linked to the parent via relation implying datetime and numeric values (terrible design, I know.)
Now, when retrieving the data, the date will print ok, using a yyyy/mm/dd hh:mm:ss format, but I cannot make new entries, or inserts from the forms as SQL server will complain that the text-data overflowed the capacity for a datetime, or that the engine cannot find the parent record.
I'm using a file-based DSN to connect to the backend.
Thanks for any insight in the matter,
Pascal
Dates are stored in MS Access as numbers. You can set custom formats for controls, such as dd/mm/yyyy, but it nearly always means a deeper problem.
More info: http://office.microsoft.com/en-ie/access-help/format-property-date-time-data-type-HA001232739.aspx
I am writing a small utility to copy a database from a proprietary ODBC database into a SQL Server database. Everything is working great, except when I use SQLBulkCopy to copy over the data. It works in most cases, but not when it's trying to copy a TIME field into a SQL DATETIME. I get this error:
The given value of type TimeSpan from the data source cannot be converted to type datetime of the specified target column.
When I create the schema in SQL Server I have to make the DATE and TIME fields DATETIME types in SQL Server, so there is no way around this. I wanted to use SQLBulkCopy so I didn't have to manually read through every record in every table and wrap logic around the special cases. Before I go down that road, is there another way I can do this? I have no control at all on the source database schema or content.
I assume you are dealing with pre-SQL Server 2008. SQL Server 2008 has DATE and TIME data types.
I think you would have to use a DataTable which matched the SQL Server schema and load this from your source reader, appropriately changing any TIME to a DATETIME by adding date information (e.g. 1/1/1900). Then use WriteToServer(DataTable). You might want to do it in batches, since you may use a bunch of memory reading it all into a DataTable.
Any particular reason you can't use SSIS?