VB.Net dynamic SQL WHERE DateField = ‘2012-12-13’ converts to US date and possibly throws error if then invalid

VB.Net dynamic SQL WHERE DateField = ‘2012-12-13’ converts to US date and possibly throws error if then invalid

Was only happening on Windows XP, possiby 32-bit computers.
Windows 7 64-bit were ok.

In this case it was against a view. Solved by changing view:

SELECT ts.JobSheetID
, CAST(js.DateMJSAASdatetime2(0)) AS DateMJSA
,js...
FROM

SQL Agent Job – SSIS Integration package which uses VFPOLEDB and SQL 2012 fails

Various error messages received including:

Description: ADO NET Source has failed to acquire the connection DataReaderSrc with the following error message: “ERROR [IM014] [Microsoft][ODBC Driver Manager] The specified DSN contains an architecture mismatch between the Driver and Application”

Solution:

  1. Create a SQL Credential
    1. SSMS > Security > Credentials
  2. Create a SQL Server Agent Proxy
    1. SSMS > SQL Server Agent > Proxies > SSIS Package Execution > New Proxy
  3. Return to job step in question > Run as > new proxy
  4. Execution options > Use 32-bit tick

Workaround for SQL Server 2012 64-bit connection to 32-bit VFPOLEDB – Stored Procedure and SQL Agent

In SQL Server 2005 32-bit > Linked Servers > Providers > VFPOLEDB was present, (with in process ticked)
This provider was not available in SQL Server 2012 64-bit

Workaround: Running a stored procedure from SQL 2012 back to to SQL 2005

  1. Create a linked server to the SQL Server 2005 32-bit. RPC = Remote Procedure Call. You need to set RPC Out to True. Possibly RPC as well.
  2. Then use/move/write queries in SQL 2005 and call them from SQL 2012 procedures using:
  3. EXECUTE [<SQL2005 server name>].[Database name].[Schema].[procedure]
  4. May need to add login to SQL 2005 and grant permission

Workaround: SQL Agent jobs that call procedures still not working

Executed as user: NT SERVICE\SQLSERVERAGENT. Cannot initialize the data source object of OLE DB provider “VFPOLEDB” for linked server “”. [SQLSTATE 42000] (Error 7303)  OLE DB provider “VFPOLEDB” for linked server “” returned message “Invalid path or file name.”. [SQLSTATE 01000] (Error 7412).  The step failed.

  1. Change the job type from Transact SQL to Operating System (CmdExec)
  2. Command = osql -E -Q “EXEC <sql 2012 db name>.dbo.<sp name>”

Maintenance Plan fails on Notify Operator – “No global profile …”

With thanks to

http://aartemiou.blogspot.co.uk/2011/02/no-global-profile-is-configured-specify.html


Even though the first three tasks were executed successfully, when I checked the history of the job that undertakes the execution of the maintenance plan, there was an error message on the last task that is the “Notify Operator” Task.
A part of the error message is the following:
“No global profile is configured. Specify a profile name in the @profile_name parameter.”
So, what does the above error message tell us? It actually says that upon the task’s execution, it cannot find a Database Mail profile in order to use it for sending the email notification.
To overcome this problem, you can set one of the available Database Mail profiles as the default one.
In SQL Server 2005 or 2012 you can do this in the following way through SSMS:

  1. Management — Database Mail (double-click or right-click – Configure Database Mail).
  2. Click on Next.
  3. Manage profile security.
  4. Click on Next.
  5. Then you will see a list with all the available database mail profiles. You have the option to select one of these profiles to be the Default Profile (be selecting ‘Yes’ in the combo box).
  6. Click on Next.
  7. Click on Finish.

SQL: Windowed functions can only appear in the SELECT or ORDER BY clauses

Use a CTE. Problem could occur in

WITH myCTE AS
(
SELECT WO, QuoteNo, EntryNo = ROW_NUMBER() OVER (PARTITION BY QuoteNo ORDER BY WO)
FROM dbo.Orders2006
WHERE QuoteNo IS NOT NULL
)

UPDATE dbo.Orders2006
SET EntryNo = myCTE.EntryNo
FROM dbo.Orders2006
INNER JOIN myCTE ON myCTE.WO = dbo.Orders2006.WO

 

With thanks to:

http://stackoverflow.com/questions/1466963/sql-row-number-function-in-where-clause

DataTable detect column changed using ColumnChanged event

Background

Because of disconnected nature of VB.Net databinding I have users who have come from MS Access instant save who in .Net are concerned that they fogot to press save. Hence I added CheckForChangesAndPromptForSave. However this is firing too much. I have too much code and something must be changing a column but need to detect which and probably stop changing it.

Solution

Open Dataset and select table with changes. View Code. This generates new code window if not present. On table event use the ColumnChanged event.

Partial Class dsBusiness
    Partial Class QuoteDataTable

        Private Sub QuoteDataTable_ColumnChanged(sender As Object, e As System.Data.DataColumnChangeEventArgs) Handles Me.ColumnChanged
            MsgBox(e.Column.ColumnName)
        End Sub

    End Class
End Class

Windows Remote Assist – A program could not start

The client was using an XP machine inside a network. Tried to get them to send me a remote assist request, but on send or save invite got a message:

Title: Message from webpage
Message: A program could not start. Please try again.

I had several go’s myself with changing several functions, but then spoke to the people who set up the network who said that security would have to be changed. They suggested that we use: Join-Me instead. Join-Me seemed easy enough to use.

Visual Studio 2010 with Crystal Reports error ‘ The type initializer for ‘CrystalDecisions.Shared.SharedUtils’ threw an exception’

On a x64 PC

‘ The type initializer for ‘CrystalDecisions.Shared.SharedUtils’ threw an exception’

Project properties > Compile > Advanced Compile Options > Target CPU change to X86

Or on install of SAP Crystal Reports Version for Visual Studio 2010 tick box for running x64

With thanks to

http://www.logicaltrinkets.com/wordpress/?p=213

and for runtime

http://www.businessobjects.com/jump/xi/crvs2010/us2_default.asp

 

Error: Format of the initialization string does not conform to specification starting at index 0

The connection string is wrong

Add settings connection string to an existing Dataset

Scenario / Solution

Existing project with no settings file and related connection string

Do not start by creating the settings file. Instead start with the dataset.

Configure an existing table and retreat back through the wizard to:

“Do you want to save the connection string to the application configuration file?”

Tick Yes and give it a name.

This will generate the settings files and the app.config, but will also generate a lot of errors. The errors include

“‘et’ is not declared. It may be inaccessible due to its protection level”

“‘ype’ is not declared. It may be inaccessible due to its protection level”

Save and close the dataset. You then get additional errors:

“‘conStrApplication’ is not a member of ‘<namespace>'”

Navigate to the first error “‘ype’ is not declared…”

and after “Public ReadOnlyProperty conStrApplication() AsString” type a return and delete. This should clear all errors.