Welcome Guest, Not a member yet? Register   Sign In
Can't select MSSQL table
#1

(This post was last modified: 12-10-2018, 12:40 PM by wuk986.)

I am connected to a MSSQL Server (10.50.2550.0) and I want to select a table from a database where I have read permission.

The database configuration looks like this:
Code:
$db['lardis_mssql'] = array(
   'dsn'    => '',
   'hostname' => '192.168.120.xxx',
   'username' => 'username',
   'password' => 'password',
   'database' => 'LardisLog',
   'dbdriver' => 'sqlsrv',
   'dbprefix' => '',
   'pconnect' => FALSE,
   'db_debug' => (ENVIRONMENT !== 'production'),
   'cache_on' => FALSE,
   'cachedir' => '',
   'char_set' => 'utf8',
   'dbcollat' => 'utf8_general_ci',
   'swap_pre' => '',
   'encrypt' => FALSE,
   'compress' => FALSE,
   'stricton' => FALSE,
   'failover' => array(),
   'save_queries' => TRUE
);

The connection is successfull and the database has the following tables:
  • dbo.Events
  • dbo.Users
  • dbo.Networks
The query in the model looks like this:

Code:
$query = $this->db->get('Events');
//$query = $this->db->query("SELECT * FROM Events");
return $query->result_array();

The result looks like this:

Quote:A Database Error Occurred
Error Number: HY000/1
no such table: Events
SELECT * FROM "Events"
Filename: C:/xampp/htdocs/ci3/system/database/DB_driver.php
Line Number: 691

When I leave "database" in the database.php empty, I get the same result. Therefore I think there is an misconfiguration at the sql server.
could this be possible or where could be the error?

Thanks in advance

PS: In the SQL Server Management Studio the standard database of my user is "LardisLog" and the sorting is "Latin1_General_CI_AS"
Reply
#2

Did you install Microsoft Drivers for PHP for SQL Server on windows?

Microsoft Drivers for PHP for SQL Server


7 Steps to make SQL Server and Codeigniter Works
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

(12-11-2018, 09:28 AM)InsiteFX Wrote: Did you install Microsoft Drivers for PHP for SQL Server on windows?

Microsoft Drivers for PHP for SQL Server


7 Steps to make SQL Server and Codeigniter Works

Yes, the driver are installed and working.
The connection to the SQL Server is established, but it seem that I can't find any table in the database.

On the SQL-Server I should have only read permission as db_datareader and when I check the schema db_datareader there is no permission specified  Huh

I think I have a talk with the admin Confused
Reply
#4

You may also need the Microsoft ODBC drivers installed.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#5

(This post was last modified: 12-15-2018, 07:26 AM by wuk986.)

(12-11-2018, 12:53 PM)InsiteFX Wrote: You may also need the Microsoft ODBC drivers installed.

I have installed the ODBC driver as you recommended but without success  Sad

As i wrote the connection is successfull, but i can not find the existing table in the database.
Quote:A Database Error Occurred
Error Number: HY000/1
no such table: Events
SELECT * FROM Events
Filename: C:/xampp/htdocs/ci3/system/database/DB_driver.php
Line Number: 691


My thoughts are, that there is an misconfiguration on the sql server, and it might be possible that the admin of the SQL server is not familiar with the server as he schould be Undecided

Thanks in advance
Reply
#6

PHP.net SQLSRV - Requirements

How to SQL Server Database Connection (MSSQL) in Codeigniter 3

You may need to add the port number also.

If these do not work check your php installation using php

PHP Code:
<?php
// Show all information, defaults to INFO_ALL
phpinfo();
?>

DO NOT LEAVE ON A SERVER! DELETE IT WHEN DONE.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#7

(12-15-2018, 09:51 AM)InsiteFX Wrote: PHP.net SQLSRV - Requirements

How to SQL Server Database Connection (MSSQL) in Codeigniter 3

You may need to add the port number also.

If these do not work check your php installation using php

PHP Code:
<?php
// Show all information, defaults to INFO_ALL
phpinfo();
?>

DO NOT LEAVE ON A SERVER! DELETE IT WHEN DONE.

Big thanks for you support!

Everything, including the port on the client side, is set to "1433". But I do not know if the port is set correctly on the SQL server.
The link "how to SQL Server Database Connection (MSSQL) in Codeigniter 3" I have forwarded to the SQL-Serveradmin.

remark sqlcmd will show me the selected table.

Kind regards
Reply
#8

Thanks for all your support.
The config of the database and codeigniter is correct and the error was, that I have a primary database (SQLite) and the second MSSQL Database and I always tried to connect to the SQLite database.


PHP Code:
public function __construct()
 
 {
 
   $this->mssql_db $this->load->database('lardis_mssql'TRUE);
 
 }

 
 public function get_tetra_log()
 
 {

 
 $get_where_array = array(
 
     "RadioID" => "******-*****-*****-****-**********"
 
 );

 
   $query $this->mssql_db->get_where('Events'$get_where_array);
 
   return $query->result_array();
 
 
Reply
#9

This has also happened to me, so i never try to use different databases
No SEO spam!
Reply




Theme © iAndrew 2016 - Forum software by © MyBB