Quantcast
Channel: SQL Server Data Access forum
Viewing all 4164 articles
Browse latest View live

ODBC Driver for SQL Server (with Access): workaround for idle-timeout force-close error #10054

$
0
0

I've noticed a problem--and this is a problem that's been around for a few years at least, though it's new to me--where if you use Access 2016 to link to some SQL Azure tables via the ODBC (v13.1) driver, that upon being idle for about a half hour, this error will come up.

I've tried maxing out the connection retry count, and later the interval values, in the System DSN for the driver, but it didn't help or even delay the problem. Short of not being inactive, is there anything to be done?



Microsoft ODBC Driver 13.1 for SQL Server and OPENROWSET

$
0
0

This is a simple question that I've found zero articles on.

How do I utilize the ODBC 13.1 driver using OPENROWSET? I'm running the OPENROWSET on SQL Server 2016 going to SQL Server 2014, and vice versa.

Thank you very kindly!

My Database cannot save the data inserted

$
0
0

Hello guys !

I have a liitle problem :i have a task to create an app for a car rental bussiness and i have to create a database where i need to keep information about firm's cars:producer,model,the year when that car was made,engine capacity,registration number,the fuel's type,Max number of passengers,etc.I made a service-based Database and,using an interface,i added a car in the main table(The "Cars" table).The problem is that,when i cliked the "Add" button and I went back to the table,no data has been saved,even if the app informed  me that the car was successfully added.I will attach my code down below :

 string connectionstring = ConfigurationManager.ConnectionStrings["WindowsFormsApplication3.Properties.Settings.MasiniConnectionString"].ConnectionString;
            SqlConnection conexiune = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename="+@"E:\Microsoft Visual\Firma de inchirieri auto\WindowsFormsApplication3\Masini.mdf"+";Integrated Security=True;Connect Timeout=30");
            conexiune.Open();
            SqlCommand comanda = new SqlCommand(@"INSERT INTO Masini( Producator,
                                                                      Model,
                                                                      An_Fabricatie,
                                                                      Capacitate_Motor(cmc),
                                                                      Numar_Inmatriculare,
                                                                      Tip_Combustibil,
                                                                      Numar_Pasageri,
                                                                      Pret_Cumparare,
                                                                      Data_Cumpararii,
                                                                      Pret_Inchiriere,
                                                                      Detalii_Asigurare)
                                                  VALUES(@val1,@val2,@val3,@val4,@val5,@val6,@val7,@val8,@val9,@val10,@val11)",conexiune);
            comanda.Parameters.AddWithValue("@val1",producerBox.Text);
            comanda.Parameters.AddWithValue("@val2", modelBox.Text);
            comanda.Parameters.AddWithValue("@val3", int.Parse(yearBox.Text));
            comanda.Parameters.AddWithValue("@val4", int.Parse(engineBox.Text));
            comanda.Parameters.AddWithValue("@val5", numberBox.Text);
            comanda.Parameters.AddWithValue("@val6", fuelBox.SelectedItem.ToString());
            comanda.Parameters.AddWithValue("@val7", int.Parse(passengersBox.Text));
            comanda.Parameters.AddWithValue("@val8", int.Parse(buyPriceBox.Text));
            DateTime data_cumparare = Convert.ToDateTime(buyDateBox.Text);
            comanda.Parameters.AddWithValue("@val9", data_cumparare);
            comanda.Parameters.AddWithValue("@val10", int.Parse(loanBox.Text));
            comanda.Parameters.AddWithValue("@val11", assuranceBox.Text);

            MessageBox.Show("Adaugare efectuata cu succes!","Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
            Close();

Please help me.Thank you very much!

query to know at what sample percentage stats last updated

$
0
0

To find the status last update date it can be done simply with this query:

SELECT OBJECT_NAME(object_id) AS [ObjectName]
      ,[name] AS [StatisticName]
      ,STATS_DATE([object_id], [stats_id]) AS [StatisticUpdateDate]
FROM sys.stats;

On top of knowing when (date and time), what table can I also query to find at what sampling percentage the stats were last updated with? Knowing if stats executed is valuable, but know when they executed with what stat collection is even more valuable.

OLE DB provider "OraOLEDB.Oracle" for linked server "XXXXXX" returned message "New transaction cannot enlist in the specified transaction coordinator.

$
0
0

Hi Friends,

  I am using Sql server 2005 and when I execute a procedure which is using some oracle linked server in it and fetching information accordingly . It is working perfectly fine for most of the things but some times it is giving below error .

 

Perfectly executing with the below :

exec

GetRecords_test '1058989'

Giving error when I try to insert the data to some temp table from the procedure output as below

1)

EXECUTE

sp_ExecuteSQL N'INSERT into #MyTempTable exec GetRecords_test ''1065252'''

2) tried with the below also by creating temporary table with the same columns which are output from the procedure, but no luck

insertinto #MyTempTableexecGetRecords_test '1065252'

No luck :( :( . Please post if any body has same issue come across

Thanks in advance

Regards

Ravi

The operation could not be performed because OLE DB provider "OraOLEDB.Oracle" for linked server "XXXXXX" was unable to begin a distributed transaction.

OLE DB provider "OraOLEDB.Oracle" for linked server "XXXXXX" returned message "New transaction cannot enlist in the specified transaction coordinator. ".


Ravishankar Maduri MCTS,MCPD,MCP


Cannot Restore .BAK files!

$
0
0
I don't understand what is going on but for some reason, I cannot restore ANY .bak files... EVER using SQL Server Management Studio! This has been the most frustrating thing ever.

I've tried Northwind, Adventureworks, now Wide World Importers, every single time I get this error and/or SSMS completely locks up. I'm on Windows 10 most recent version, SSMS most recent version (just updated and re-tried), Intel i7, 16GB of RAM... This makes absolutely no sense whatsoever and nobody seems to understand what is even causing this. If there is no immediate fix, is there at least somealternate way to install a sample DB that's NOT a .bak file? Thanks so much!!!

Please note: As you can see in the photo, I am using the proper directory. I've followed instructions from 4 different sources now which all explain to put the file into the Backup folder inside SQL Server's folders, which is exactly where it is.

post upgrade to Express 2014 - no remote connections allowed

$
0
0

I received a new update to an existing ESRI GIS server. 10.5 required SQL Express 2014, so I had to update that too. After this update there were SPs and CUs for Express 2014. The GIS upgrade went smooth. I was able to view my GIS data immediately locally. But, no GIS client or SQL Server Management could connect remotely.

I called ESRI support and was sent to their DB configuration group. We went through all the typical configuration steps and found nothing. ESRI had more than one staffer observing the effort. After 3 hours we gave up. They told me to call MS for support.

It turned out that when the Express 2014 installer was working it also installed a needed service to the new instance. At this point MS engineers SHOULD have looked for existing instances and services. They SHOULD have matched the settings of those instances, since this was an UPGRADE to an EXISTING system, but they failed to do this. Shame on them!!

I later found a thread here that provided the missing information. MS had disabled by default the new instance of SQL Server Browser!

Really? But, my previous service was ENABLED. Yet, they did enable the SQL configuration to allow remote connections. MS engineers got only half the job right. Do they not test such things? Why go half way?

Why not prompt the user if such a required services is needed to make the dB actually useful, if they were uncertain.

It is easy to see how a novice (me) and specialist who do data connections all day long missed this setting. None of the above ever dreamed MS would change the configuration half way rendering it useless as a dB. But, now we know. Sure the burden of ignorance is on us all, but why waste so many people's time?

SQL Sever 2016 breaks linked table updates for MS Access using native client or ODBC

$
0
0

The new datetime conversion rules for SQL Server 2016 as described at msdn.microsoft.com/en-us/library/ms143179.aspx break MS Access updates to rows datetime columns. Workaround is to set DB
compatibility back to 120, but that will cause us problems soon as new functionality is needed for projects in progress.

To reproduce:

CREATE TABLE
MsAccessTest

(

c1 INT NOT NULL PRIMARY KEY ,

c2 DATETIME NOT NULL,

c3 CHAR NOT NULL

);

INSERT INTO
dbo.MsAccessTest

( c1, c2, c3 )

VALUES ( 0,'2016-12-28 10:33:14.876', 'A' ),

( 1, '2016-12-28 10:33:14.876', 'B' ),

( 2, '2016-12-28 10:33:14.876', 'C' ),

( 3, '2016-12-28 10:33:14.876', 'D' );

Then link this table to MS Access and attempt to update a row. The not-easily rounded datetime value results in an update statement like this being executed.

exec sp_executesql N'UPDATE "dbo"."MsAccessTest" SET "c3=@P1 WHERE c1" = @P2 AND "c2" = @P3 AND "c3" = @P4',N'@P1
char(1),@P2 int,@P3 datetime2,@P4 char(1)','g',0,'2016-12-28 10:33:14.8770000','A'

However the datetime value does not match as the datetime2 version of this value which is actually
2016-12-28 10:33:14.8766667. Causes the update to fail and MS Access throws a "Write Conflict" error.



Excel 2016 for Mac SQL Server ODBC issues with connecting to SQL Server

$
0
0

I am having trouble connecting to a SQL Server (2008 R2) via the new Excel 2016 for Mac SQL Server ODBC New Database Query feature.    We also have another SQL Server (SQL Server Express 2012) that I also access via ODBC on Windows Excel 2016.


I tried to follow the Office Support info available on this link:

https://support.office.com/en-us/article/Import-data-from-a-database-in-Excel-2016-for-Mac-bc139dc9-861f-4435-9f0d-82c6121dcea5#feedbackText 


I successfully manage to query the same SQL server in Windows using ODBC connections to the SQL server on our LAN. However, I try the same or similar settings with my Mac's Excel 2016 and I do not succeed in making the connection.   I do the following:

I started with the following settings:

Server Name: 10.66.4.4

Database: MSSQLSERVER1

Authentication:

Method: Username/Password

User Name: crystal

Password:  *******

Error Message: [SqlServerODBC] (15) Failed to connect to the SQL Server instanceL [28000]: Login failed for user 'crystal'.

I then found some support that stated that I need to specify the Port number for the server (60198):

Server Name: 10.66.4.4,60198

Database: MSSQLSERVER1

Authentication:

Method: Username/Password

User Name: crystal

Password:  *******

Error Message: [SqlServerODBC] (15) Failed to connect to the SQL Server instance: [HY000]: Connection broken unexpectedly

Now the error code changes from 28000 to HY000 and the message reads "Connection broken unexpectedly".   


I also tried without specifying the actual Database name with the same result:

Server Name: 10.66.4.4,60198

Database: 

Authentication:

Method: Username/Password

User Name: crystal

Password:  *******

Error Message: [SqlServerODBC] (15) Failed to connect to the SQL Server instance: [HY000]: Connection broken unexpectedly

I would appreciate help with understanding where I am going wrong with my recipe to create the New Database Query.


Thanks in advance for any help.




SQL Server 2014 - Update child value based on parent's total and child's data.

$
0
0

Hi,

I have two tables - Parent with columns - ID, total and Child with columns - ID, ParentID, BoundaryValue, ChildValue.

I have to update the child's records ChildValue column based on parent's total and child's BoundaryValue column. Suppose Parent's total column for a ParentID has 20000 and Child's ChildValue column is 5000, I have to allocate 5000 if sum of all the Child's ChildValue column doesn't exceed 20000 (Parent's total). Otherwise, I have to allocate the reminder of the Parent's total value. If there is no more reminder amount in Parent's total, Child's ChildValue should be updated to zero.  Records updated should be in the sequence of the ID. I have tried with Recursive CTE but I couldn't get to the core with joining the two tables. I don't want to use cursor. Is there any option to do this with Direct UPDATE or recursive CTE?

Thanks in Advance,

Manohar


Can openrowset connect to SharePoint online?

$
0
0

Hi all,

Does anyone know if openrowset can be used to connect to SharePoint online lists? If so what you have to do to get it to work. If not is there another means to connect to SharePoint online lists? Thanks very much for having a look at this.

I use openrowset for connecting to on premises SharePoint lists and it works fine. 

I've tried connecting to an online list but it's not working. I've tried with the example connection string:

select * 
from OPENROWSET 
(
'Microsoft.ACE.OLEDB.12.0',
'WSS;IMEX=1;RetrieveIds=Yes;User ID=person@bla.com;Password=pwblabla;DATABASE=https://blabla.sharepoint.com/blasite/;LIST=blalist;', 
'SELECT * FROM LIST'
)

The error I receive is:

OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)" returned message "The Microsoft Access database engine could not find the object 'LIST'. Make sure the object exists and that you spell its name and the path name correctly. If 'LIST' is not a local object, check your network connection or contact the server administrator.".
Msg 7350, Level 16, State 2, Line 27
Cannot get the column information from OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)".

Thanks, Brian


Brian Searle

Security Issue Connecting to SQL Server 2016 with SNC/OLE

$
0
0

I have SQL Server 2016 set up on an AlwaysOn Availability Group, with a listener.

I am trying to establish a connection to the SQL database using the following with Windows Authentication:

SQLCA.DBMS = "SNC SQL Native Client(OLE DB)"

SQLCA.ServerName = "AvailabilityGroupListener,12345"

SQLCA.AutoCommit = False

SQLCA.DBParm = "TrustedConnection=1,Database='DB_Test',Provider='SQLNCLI11'"

 Now, when I try to execute the connection/application using my own account, it works perfectly.  When I try to execute the connection using a test account, it gives the following error (executed from Windows Server 2008R2):

SQLSTATE=28000

Microsoft SQL Server Native Client 11.0

Login failed for user 'Domain\Test_User"

I have given the test account and my account all have the appropriate SQL permissions (datareader).   I have even tried granting sysadmin to the test account. 

The SQL Instance is configured for mixed mode authentication, remote connections are enabled, and TCP/IP is enabled as well.

Can anyone tell me why I am getting that security error?

How to embed the user name in /etc/odbc.ini

$
0
0

I am using the driver msodbcsql-13.0.0.0.tar.gz for Linux

My app needs to include the username and password in the DSN entry, like

[sqlserver]
Driver = ODBC Driver 13 for SQL Server
Trace = no
Server = 127.0.0.1,1433
Database= demo
UID =  userdemo
Password=  mysecret

but it does not work, no matter what I do. With other odbc drivers it does work fine.


ff

An internal network library error has occurred. A network level syntax error has occurred---Data Access Tool to db2

$
0
0

I tried to use Data Access Tool (v4.0) to connect a db2 instance.

The db2 and Data Access Tool are installed on same machine.

It ran into the error when I click the 'Connect'

Here was the connection string:

Provider=DB2OLEDB;User ID=test1;Password=Aa1!Aa1!;Initial Catalog=dbtest;Network Transport Library=TCPIP;Host CCSID=37;PC Code Page=1252;Network Address=test017330VM;Network Port=50000;Package Collection=MSPKG;Process Binary as Character=False;Units of Work=RUW;DBMS Platform=DB2/MVS;Use Early Metadata=False;Defer Prepare=False;DateTime As Char=False;Rowset Cache Size=0;Datetime As Date=False;AutoCommit=True;Authentication=Server;Decimal As Numeric=False;Derive Parameters=False;LoadBalancing=False;Persist Security Info=True;Cache Authentication=False;Connection Pooling=False;

Environment

===

Server name:test017330VM

OS:Windows Server 2012 R2 Datacenter

DB2 port:50000

DB2 Version:DB2 v11.1.1010.160

Database:dbtest.  (this is created by 'DB2 Create database dbtest'

Local user:test1   . This user is a member of windows group 'testgroup' which belongs to DB2 SYSADM_GROUP

                    UPDATE DBM CFG USING SYSADM_GROUP testgroup

Password:Aa1!Aa1!;

Queries

===

1)What is Package Collection?   Is MSPKG a correct value? If not, how do i get the value?

2)Is 'DB2/MVS' applicable for 'DBMS Platform' when DB2 is installed in windows?

3)Do i need to specify instance name?

Thanks very much


Safe handle has been closed

$
0
0

My Web Page is trying to execute a stored procedure and following error is thrown. Please note that when application pool is reset the error goes away.

BController::D_DailyTrades||BAction::1||ActionKey::View
5 : clsBDal_dsResponse_D_DailyTrades
ERROR   : MyAppException
clsCn_GetDs(cmd)
Safe handle has been closed
Source  : ISACW
Method : System.Data.DataSet GetDs(System.Data.SqlClient.SqlCommand)
Stack    :    at ISACW.clsCn.GetDs(SqlCommand Cmd)
   at ISACW.clsBDal.dsResponse(BasePage mPage)
 
Inner Source  : mscorlib [ObjectDisposedException]
Inner ERROR   : Safe handle has been closed
Inner Method : DangerousAddRef(Boolean ByRef)
Inner Stack    :    at System.Runtime.InteropServices.SafeHandle.DangerousAddRef(Boolean& success)
   at SNINativeMethodWrapper.SNIPacketReset(SafeHandle pConn, IOType ioType, SafeHandle packet, ConsumerNumber consNum)
   at System.Data.SqlClient.TdsParserStateObject.WriteSni()
   at System.Data.SqlClient.TdsParserStateObject.ExecuteFlush()
   at System.Data.SqlClient.TdsParser.TdsExecuteRPC(_SqlRPC[] rpcArray, Int32 timeout, Boolean inSchema, SqlNotificationRequest notificationRequest, TdsParserStateObject stateObj, Boolean isCommandProc)
   at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
   at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
   at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
   at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior)
   at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
   at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
   at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)
   at ISACW.clsCn.GetDs(SqlCommand Cmd)
 


SQL Data Recovery

$
0
0

We include a server (Windows 2008 r2) with SQL database due to virus (ran some ware) out database files of SQL are encrypted with virus.

Is there some option of FREE tool to recover/back database of SQL files from back date. (When they are not encrypted)

Thanks in advance,
Techdili

Error when connecting !

$
0
0

Hello,

I'm trying to connect from my workstation to the sql server (sql 2008 r2) with SQL Server Management Studio 2014.
On the server the same user and pw exists as on the workstation.

So I use Windows Authentication.

I get the following error:

Cannot connect to ... (servername)
Login failed for user servername\Guest (Microsoft sql server error: 18456)

Anyone seen this?

tnx

frank

JDBC Eclipse

$
0
0

Hi,

I am trying to use the JDBC driver with Eclipse IDE to connect to a SQL Server on Linux instance.

Here is my code so far

public static void SQLtest() {
		String userName = "SA";
		String password = "****";
		String url = "jdbc:sqlserver://192.168.254.16:1434;integratedSecurity=true;";
		try {
			Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
		} catch (ClassNotFoundException e) {
			System.out.println("Finding Driver Failed");
			e.printStackTrace();
		}
		try {
			System.out.println("Establishing Database Connection...");
			Connection conn = DriverManager.getConnection(url, userName, password);
		} catch (SQLException e) {
			System.out.println("Connection Failed");
			e.printStackTrace();
		}
		finally {
			System.out.println("Connection Successful!");
		}
	}

and here is the error that I get...

com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host 192.168.254.16, port 1434 has failed. Error: "Connection timed out: no further information. Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall.".

about sql server errors

$
0
0
i am getting some errors in my sql server like some ERROR 40,ERROR,25,& etc. like this please help me.

Logon problems after migration from SQL Server 2005 to 2012

$
0
0

We have recently migrated the SQL Server from 2005 to 2012. User gets login failure when connected to 2012 server; but can successfully login in 2005 server using the same connection string information. In both the servers, individual user logins are not added.

How access is given to users if not added directly in logins.

Is it right, that the local group SQLServer2005MSSQLUser group is used to grant access to users? Is it possible to view the members of this group?

How this is being handled in 2012 as the security model is changed. I don't have experience in SQL Server and would like to get guidance in fixing this logon problem.

Thanks for the help!


Viewing all 4164 articles
Browse latest View live


Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>