I'm attempting to export data from Sage 50 database. I have managed to create a connection to the database however whenever I perform a query I have the following error message.
Warning: odbc_exec(): SQLColAttribute can't handle SQL_DESC_OCTET_LENGTH: [S1C00] Driver not capable in C:... on line 4
I have Attempted to change the cursor to SQL_CUR_USE_CODE as suggested on PHP.net
I am also sure it is connecting as when I enter a table name that doesn't exist then I am receiving this error.
Warning: odbc_exec(): SQL error: Table not found, SQL state S0002 in SQLExecDirect in C:... on line 4
$conn = odbc_connect("TestDB", "Manager", "", SQL_CUR_USE_ODBC);
$sql="SELECT * FROM STOCK";
$result=odbc_exec($conn,$sql);
Thanks in advance
I was having a similar issue with a c# application, but my solution may have some pertinence here and I hate to see someone go through the stress that I did. Here's what I did to fix my issue:
In the ODBC Data Source Administrator, select your Pervasive ODBC Client Interface
Under Data Options select a database name associated with the data source of your CrystalReports.udl file. Make sure the Dictionary location is the Data directory for your company.
Make sure your select statement queries a table that are allowed by the crystal report e.g. Address, Audittr, etc. since not all tables can be queried through the Crystal reports.
Hope that helps!
Related
I'm having a problem trying to do an INSERT, it's succeeding even though it shouldn't.
My table structure:
Note: given1, given2 and given3 are required fields.
In my application I execute the following method (https://github.com/catfan/Medoo):
$this->medoo->insert('teste', ['dado2' => 11, 'dado3' => 'teste']);
This should not be accepted because data2 is of type SET, and data3 is of type INTEGER`. Even so, the insertion succeeds. Moreover, data1 is not passed as an argument, even though it is a required field.
I checked the MySQL log and got the following entries:
SET SQL_MODE=ANSI_QUOTES;
INSERT INTO "teste" ("dado2", "dado3") VALUES ('11', 'teste');
Running this SQL manually in the database, I discovered that the problem is in using ANSI_QUOTES. The database somehow accepts the insert, and instead of issuing an error message it issues a warning:
I think that is need to modify the Medoo source code or report this problem to MySQL. I do not know what to do.
MySQL version is 5.7.14
I use the MySQL Workbench 6.3.6
When mySQL server is set in STRICT mode, it produces error when you try to insert values that do not fit into a column. By calling SET SQL_MODE=ANSI_QUOTES; this strict mode is most likely disabled.
You can try to contact the author of Medoo framework or rather use another framework or just PDO to access your database.
See mysql docs on server modes for more information.
I have a PHP (CODEIGNITER) application which is generally deployed on Apache/MySQL combination. I recently deployed it on IIS8 and MS SQL 11.0.2100.60
I migrated the tables and data by using ODBC connection to migrate to Access database and then again another ODBC connection to migrate to MS SQL. I modified the configurations of my PHP application (PHP.ini, database.php, db_driver.php) to make sure it connects properly and works on IIS.
I am having problem with SQL Syntax now. When I try to run the application it does not give me database connection error (which it was giving earlier) but when I try to log in to the application (it has user authentication) - I get the following error:
Error Number: 42000
[Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Incorrect syntax near '`'.
SELECT * from ctbl_events WHERE 2017-01-11 <= startdate AND `enddate` >= 2017-01-11 and status=0 ORDER BY `ctbl_events`.`id`
Filename: C:\inetpub\wwwroot\GMS\system\database\DB_driver.php
Line Number: 330
does this mean problem is with ` symbol and if yes would I have to manually go and modify all the SQL queries in my application (would be a gigantic task) or is there any way to handle this.
As far as I know, SQL Server does not support using backticks to escape table or column names (you can use brackets instead). You can easily try this by running a simple query like
select * from `ctbl_events`
If that doesn't work, you will almost certainly have to update all the queries to replace the backticks with brackets.
Second reason the query is probably failing is the dates in your query must be enclosed in quotes, and match SQL Server's date format (this is configurable, so you may need to experiment a little).
So, the query you're trying to run should look a little like this:
SELECT * from ctbl_events
WHERE '2017-01-11' <= startdate
AND [enddate] >= '2017-01-11'
and status=0
ORDER BY [ctbl_events].[id]
Though in this case, you don't really need the brackets around table or column names - it's best to agree a standard for this and stick to it.
I'm designing a web interface for my clients database (A .mdb MS Access file). I'm using an ODBC driver to connect to it and the odbc_ functions provided by PHP.
My problem is access's 'append' queries. From what I gather, it's just inserting more rows, but something is breaking the query from executing:
INSERT INTO test ( TITLE, [LEVEL], UNITID, TITLEM, COHORTPLUSOPTIONS )
SELECT \"OPTION ONLY\" AS Expr, Units.LEVEL, UnitOptionNumbers.ID, Units.TITLE,
UnitOptionNumbers.OPTIONCOHORT
FROM UnitOptionNumbers INNER JOIN Units ON UnitOptionNumbers.ID = Units.ID WHERE
(((UnitOptionNumbers.NOAWARD)=Yes));
The most helpful error message I can get is:
[ODBC Microsoft Access Driver] Too few parameters. Expected 1.
Which isn't helpful at all. I'm confident with mySQL, but I just cannot pinpoint the problem here. Please can you help me find the reason the query wont execute, or help me figure out a work around.
Thanks for your time.
I don't have enough reputation to comment but perhaps it could be a problem with the fact that your table "test" has two fields with the same name ("TITLE")
According to Microsoft:
"This error occurs only with Microsoft Access when one of the column names specified in a select statement does not exist in the table being queried."
The solution therefore is to change
SELECT \"OPTION ONLY\" AS Expr
to
SELECT 'OPTION ONLY'
It seems the original code attempted to fill the first field with a default text value I.e "OPTION ONLY". "OPTION ONLY" was being read as a column name it seems.
Hello im developing an application where data comes from MSSQL database. Here using php odbc connection i get all the needed data to work with app. But now i have a problem:
Im looking for:
All data from mssql (assume) mssql_Table_A will be listed in this app, each row will be given with checkbox so user can check the data required, after checking When he hit save checked data will be stored in local MySQL database (assume) mysql_table_A.
So next time when he again wants few more data, this app will list all the data from mssql_table_A which dont exists in mysql_table_A.
Problem is:
If both the dataflwo were from MYSQL i would have done this where easily by using mysql select query
mysql_query("SELECT * FROM mysql_table_a WHERE NOT EXISTS (SELECT * FROM mysql_table_B WHERE thisID != thatID)")
But here how do i check data exists in mysql table and list the data from odbc mssql database.
Please help me to resolve this problem.
Thank You..
You need to use mssql_, sqlsrv_ or PDO functions to connect to MSSQL. mysql_ functions are strictly for MySQL.
Microsoft SQL Server Driver for PHP
Microsoft SQL Server
Microsoft SQL Server Functions (PDO_SQLSRV)
You will need two separate connections if you are fetching data from both.
Alternatively, you can connect to MySQL from MSSQL using an ODBC connection and perform your query on the MSSQL side.
The other answers have told you how to connect the two databases but based on your comments you still want to know how to do the comparison.
I have to assume you've got at least one column which you can uniquely identify rows in table_a which are not in table_b. If you link mysql in MS SQL Server like one answer said you can
select * from mssql.table_a where unique_column not in (select unique_column from mysql.table_b)
but this works because mssql is linked to mysql in mssql i.e., you can do one query and mssql will do the join for you.
If for some reason you cannot or don't want to link mysql to ms sql via a linked table the easiest way would be if you had some sort of timestamp in table_a. Let's say every record written into table_a has a timestamp of when it was inserted:
mysql connection does select max(timestamp) into X from mysql.table_b
mssql connection does select * from mssql.table_a where timestamp > X
There may be other ways if we knew a bit more about your data.
Firstly I'm a complete newbie when it comes to SQL Server. I have five SQL Server databases, in all of them except one I can easily do say...
SELECT TOP 10 * FROM dt_Organizers
However one of the new databases require me to do this:
SELECT TOP 10 * FROM dbuser.dt_Organizers
Note that all the tables in all databases have "dbuser" "dbamy" "dbyon" "dbmio" "dbcana" prefixes respectively, this never caused a problem before. Now if I use the query without doing dbuser.dt_Organizers it brings up:
Warning: mssql_query()
[function.mssql-query]: message:
Invalid object name 'dt_Organizers'.
I think you should have a look at
Understanding the Difference between
Owners and Schemas in SQL Server
SQL SERVER – Importance of Database
Schemas in SQL Server