Проблемы
«37000: [Microsoft] [драйвер SQL-сервера ODBC] [SQL Server] инструкции не могут быть подготовлены: Эта ошибка возникает при создании отчета.
Причина
В коде ссылки есть запятая.
Решение
SQL Server интерпретирует запятую как разделитель. Удалите запятую из кода ссылки в пакете GL и измените форматы отчета, чтобы избежать этой ошибки.
Ссылки
Нужна дополнительная помощь?
Нужны дополнительные параметры?
Изучите преимущества подписки, просмотрите учебные курсы, узнайте, как защитить свое устройство и т. д.
В сообществах можно задавать вопросы и отвечать на них, отправлять отзывы и консультироваться с экспертами разных профилей.
У меня есть сценарий PHP, который используется как учетная запись только для чтения для подключения к базе данных MS SQL.
Я работал безупречно до недавнего времени, когда администратор БД что-то изменил в моей учетной записи.
Теперь я получаю только следующее сообщение об ошибке:
E_WARNING Error in file «dbconnect.php» at line 40: odbc_connect():
SQL error: [Microsoft][ODBC SQL Server Driver][SQL Server]Cannot open
database «dbname» requested by the login. The login failed., SQL state
37000 in SQLConnect
Мой код подключения выглядит так:
<?php
$user = 'username';
$pass = 'password';
$server = 'servername';
$database1 = 'dbname';
$CharacterSet = "UTF-8";
$connection_string1 = "DRIVER = {SQL Server};SERVER=$server;DATABASE=$database1;CharacterSet=$CharacterSet";
$conn = odbc_connect($connection_string1,$user,$pass);
?>
Мне также не удалось подключиться к базе данных через ту же учетную запись через SQL Management Studio, но затем я нашел следующее сообщение в блоге, в котором предлагалось изменить базу данных по умолчанию на «master» при подключении:
Можно ли как-нибудь сделать то же самое через odbc_connect?
I’m trying to execute a stored procedure in a ms sql database using the following php:
$query = "{CALL dbo.storedProc('functionName', $date, 'id";
$resultSet = odbc_prepare($connection, $query);
odbc_execute($resultSet, array());
odbc_result_all($resultSet);
The same stored procedure works fine for a different function, and the results are selected by date like so ($date is @Searchstr):
(EventStart >= @Searchstr AND EventStart < DATEADD(DD,1,@Searchstr))
However, when I run the code, it errors without giving any specific hints as to what’s causing the error. When the query is run in management studio, the results are returned correctly.
SQL error: [Microsoft][ODBC SQL Server Driver]Syntax error or access violation, SQL state 37000 in SQLPrepare in ...
What’s causing the query to error? Could it be an ODBC bug?
Thanks in advance,
Will
Good day!
I get this error:
SQL STATE 37000 [Microsoft][ODBC Microsoft Access Driver] Syntax Error
or Access Violation, when trying to run an embedded SQL statement on
Powerscript.
I am using MsSQL Server 2008 and PowerBuilder 10.5, the OS is Windows 7. I was able to determine one of the queries that is causing the problem:
SELECT top 1 CONVERT(DATETIME,:ls_datetime)
into :ldtme_datetime
from employee_information
USING SQLCA;
if SQLCA.SQLCODE = -1 then
Messagebox('SQL ERROR',SQLCA.SQLERRTEXT)
return -1
end if
I was able to come up with a solution to this by just using the datetime()
function of PowerBuilder. But there are other parts of the program that is causing this and I am having a hard time in identifying which part of the program causes this. I find this very weird because I am running the same scripts here in my dev-pc
with no problems at all, but when trying to run the program on my client’s workstation I am getting this error. I haven’t found any differences in the workstation and my dev-pc
. I also tried following the instructions here, but the problem still occurs.
UPDATE: I was able to identify the other script that is causing the problem:
/////////////////////////////////////////////////////////////////////////////
// f_datediff
// Computes the time difference (in number of minutes) between adtme_datefrom and adtme_dateto
////////////////////////////
decimal ld_time_diff
SELECT top 1 DATEDIFF(MINUTE,:adtme_datefrom,:adtme_dateto)
into :ld_time_diff
FROM EMPLOYEE_INFORMATION
USING SQLCA;
if SQLCA.SQLCODE = -1 then
Messagebox('SQL ERROR',SQLCA.SQLERRTEXT)
return -1
end if
return ld_time_diff
Seems like passing datetime variables causes the error above. Other scripts are working fine.
- Remove From My Forums
-
Question
-
Hi
I am getting the following error when running from a client machine. What
does this mean? Please help.
Connection Failed:
SQLState: ‘37000’
SQL Server Error: 4064
[Microsoft][ODBC SQL Server Driver][SQL Server]Cannot open user default database. Login Failed.Thank you
smsemail
Answers
-
Or remove the «default database» attribute of the login so the connection doesn’t automatically try to connect to a database that they don’t have any permission to access.
Rick Byham, Microsoft, SQL Server Books Online, Implies no warranty
-
Proposed as answer by
Sunday, May 5, 2013 10:11 AM
-
Marked as answer by
Allen Li — MSFT
Thursday, May 9, 2013 9:02 AM
-
Proposed as answer by