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

Sql Server connection :- Can I keep open all the time ?

$
0
0

Hi,

This is some diffrent requirment. we have developed real time communication device and i have to be vary fast to communicat with data. now i have to check only one row in database for each time call received from the device. now i can receive the call and send required info to that device vary quickely. but now i need to compair the call data in database and then send request.

i can not afford to loose miliseconds also. so i am thinking if i open one connection and keep that open. as soon as i got a call i just query and read the data. is this a good solution.

i am not writing any thing in the database. just reading from it can any one suggest any idea ?


Regards, Preetam Ramdhave


We have an MS SQL database (I believe 2012, how can I check?). What should be my query tool?

$
0
0

The db powers an accounting package (IRIS Exchequer MS SQL Version installed 2012). I can query it using

  • The report writer in the accounting package which has access to the accounting data tables and hides a lot of system stuff that I probably don't need to see. But the report writer itself is limited and clunky compared to say MS Access.
  • MS Access - I have already made a connection and this could work. Seems to see everything the whole structure but I believe may have limitations further down the road (web awareness, multi-users and whatnot).
  • MS Query in Excel. I'm assuming you would only need or want to use this, for anything non-trivial, if you didn't have MS Access (even if the end product and presentation is/will be in Excel). We do have MS Access. Is that a reasonable statement?
  • MS Visual Studio (is that a query tool mainly, at all? I think it's a developers kit isn't it?).
  • Another specific Miscrosoft SQL front end (is this a/the Native Client?). How do I get one. If I've got it already where do I find it?
  • a non-MS product such as Crystal Reports.

I'm posting this to the data access forum, should it be in tools, somewhere else? Too many questions.

JDBC: PreparedStatement.getParameterMetaData() does not work when the SQL contains embedded newlines

$
0
0

Consider the following table

create table foo 
(
    id integer not null primary key, 
    some_data varchar(100)
);

Now the following Java Code:

PreparedStatement pstmt = connection.prepareStatement("select * \nfrom foo \nwhere id = ?");
ParameterMetaData meta = pstmt.getParameterMetaData();

will throw an Exception:

com.microsoft.sqlserver.jdbc.SQLServerException: com.microsoft.sqlserver.jdbc.SQLServerException: Unable to identify the table select *
from foo
where id = ? for the metadata.
 at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:190)
 at com.microsoft.sqlserver.jdbc.SQLServerParameterMetaData.<init>(SQLServerParameterMetaData.java:426)
 at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.getParameterMetaData(SQLServerPreparedStatement.java:1532)

When the embedded newlines are removed from the SQL, the call works.

The driver version is: 4.0.2206.100
SQL Server Version is: 11.00.2100
Java Version is: 1.6.0_31
Windows 7 64bit

When I Open Sql Connection how log it will stay open

$
0
0

Hi,

I can not afford to close and open connection due to performance. as my application retrives only one row per call what i have desided is to keep Sql connection open. every time i need data ,then i just query the database with same open connection. This functionality is developed in my server which is running continiously. if i open the connection and kept open up till how much time it will stay open ? do i need to put any special check for the connection.

i am using C# .net Fremwork 4.0, Sql Server 2008 r2


Regards, Preetam Ramdhave

INSERT using CASE Sql Server

$
0
0

I have 2 tables as follows, both tables have same IDs:

Temptable () - This table is already there

IDConsultant(C)InHose(I)RFP(R)
1YNULLNULL
2NULLYNULL
3YYNULL
4NULLYY
5YYY

Budget() - The Resource column is empty right now. Have to populate using results from temptable.

PIDResource
1C
2I
3C,I
4I,R
5C,I,R

I know this can be done with insert using cases . But i have never used cases in sql. Can anyone please help?

Thank you

~K

Stored procedure with no-rows-affected UPDATE causes SQLExecute to return SQL_NO_DATA in ODBC SQLNCLI

$
0
0

When using ODBC invoke a stored procedure, if the first statement in the procedure performs an UPDATE that affects zero rows, the "SQL Server Native Client 11.0" ODBC driver returns SQL_NO_DATA from SQLExecute. 

I do not see this behavior when using the original "SQL Server" ODBC driver.

Is this correct behavior? It doesn't seem to be. The ODBC documentation says that SQL_NO_DATA should returned from a 3.x driver to a 3.x client when SQLExecute "executes a searched update, insert, or delete statement that does not affect any rows at the data source".

For reference:
* Windows Server 2008 R2, (version 6.1 build 7601 SP1) 64-bit

* Drivers:

SQL Server 6.01.7601.1751 (11/20/2010)

SQL Server Native Client 11.0 2011.110.2100.60 (2/11/2012)

Windows storage server: how to store databases

$
0
0

Hi,

I have a windows 2008 storage server and I want to use it to hold my database(SQL srever database). How do I do that? I dont think I can load SQL server onto the storage server. But i believe I can use some middle ware to store my DB.


Sanchia

Frequent Timeout Expired Sql Exceptions

$
0
0

Hi

I Googled this problem everywhere but to find no proper solution, Now coming to my problem

am working on a webapplication using vs2008 and sql server 2008 in c# with LINQ and asp.net 

the project has gone live  and my database size is already 3.5 GB.. now this applications gives random timeout expired exceptions everywhere in the application. my web config has command timeout of 1000 also tried increasing it to 3000 and more but with no result.

please help me solving this issue, as this project is live I need urgent help.. the exact error am getting everywhere is 

System.Data.SqlClient.SqlException: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.


odbc data source from client to SQL Server Express 2012 on server

$
0
0

I have tried creating an odbc connection from my client Windows 7 computer to SQL Server 2012 Express on our small business server with no success.

On the server:

I've configured a fixed port in SQL Server Configuration Manager to allow connections on port 1433 (also getting rid of the '0' in dynamic connections)

I've restarted the instance in SQL Server Management Studio.

I've opened the Windows Firewall and created a new Inbound Rule to allow connections on port 1433.

On the Windows 7 client:

I've tried creating a odbc data source with both ODBC Driver 11 for SQL Server and also with SQL Server Native Client 11.0.  I can't get either of these to work.  At the end of the creation wizard, I use the"Test Data Source" button and receive the following:

Microsoft ODBC Driver for SQL Server Version 11.00.2270

Running connectivity tests...

Attempting connection
[Microsoft][ODBC Driver 11 for SQL Server]SQL Server Network Interfaces: Error Locating Server/Instance Specified [xFFFFFFFF]. 
[Microsoft][ODBC Driver 11 for SQL Server]Login timeout expired
[Microsoft][ODBC Driver 11 for SQL Server]A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online.

TESTS FAILED!

There seems to be a lot of people giving solutions to this but they all seem to cover the same material.  There must be something that I'm missing.

Error while connecting between servers-An error has occurred while establishing a connection to the server- Error 40

$
0
0

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) (Microsoft SQL Server, Error: 53)

We have 4 colocated servers that connect to a database on main server. I am getting this error in one of the colocated server and the rest are working fine.

I have checked the firewall settings. Can someone suggest me other possible reasons of why this could be happening.


sqlserver 2012 connectivity from perl

$
0
0

Hi Team,

We are trying to achieve connectivity to sqlserver 2012 from perl. But before that we wanted to check the connectivity from isql.

We are getting the below error  while testing in linux environment.

[IM004][unixODBC][Driver Manager]Driver's SQLAllocHandle on SQL_HANDLE_HENV failed
[ISQL]ERROR: Could not SQLConnect

Could you please help to identify the issue and help on with the possible approaches to resolve this issue.

Thanks,

Venugopal

Micorsoft SQL Server, Error: 5171

$
0
0

I get the following error while attaching database in 2008 R2:

Msg 1813, Level 16, State 2, Line 1

Could not open new database 'ERECP-NEW2012'. CREATE DATABASE is aborted.

Msg 1813, Level 16, State 2, Line 1

Could not open new database 'ERECP-NEW2012'. CREATE DATABASE is aborted.

Msg 824, Level 24, State 2, Line 1

SQL Server detected a logical consistency-based I/O error: incorrect pageid (expected 1:9; actual 5749:-96032662). It occurred during a read of page (1:9) in database ID 8 at offset 0x00000000012000 in file 'E:\ERECP-NEW2012_Data.mdf'. Additional messages in the SQL Server error log or system event log may provide more detail. This is a severe error condition that threatens database integrity and must be corrected immediately. Complete a full database consistency check (DBCC CHECKDB). This error can be caused by many factors; for more information, see SQL Server Books Online.

Microsoft SQL Server, Error: 5171

$
0
0

how to correct the following error?

.mdf is not a primary database file. (Microsoft SQL Server, Error: 5171)

error in MS SQL 2008R2 server while attaching databasefile.

Unable to connect to remote SQL Server ; issue with dbopen

$
0
0

Hi, Am new to SQL Server. I started writing C Code for DB-Library. I have issue with dbopen (http://msdn.microsoft.com/en-us/library/aa937054(v=sql.80).aspx). When I run the program, it is unable to recognize the server name of the remote SQL Server instance.

What I did on the remote machine

1. Installed SQL Server Express. Turned off Windows Firewall (initially, just to see if am able to connect ; later, I'll open only for port 1433). Checked that am able to ping the SQL Server machine from my machine.

2. Trying to use dbopen() to connect to the remote server, but it keeps saying 'unable to connect' & returns NULL. I initially had set servername (for loginrec in dblogin()) to just the remote instance name, but 

   DBSETLUSER(loginRec, dbUserName);

    DBSETLPWD(loginRec, dbPwd);

DBSETLHOST(loginRec, dbHostName);

Then, dbopen() gave the error SQLECONN (Unable to connect: SQL Server is unavailable or does not exist.)

but later I removed the DBSETLHOST setting and set the servername (which am passing in as param to dbopen()) to 'hostname\\sqlserverinstancename'. Now, it doesn't seem to return any error code as previously, but also doesn't connect to the remote server. dbopen() now simply returns NULL.

What is the exact format to specify the hostname, instance name and port to dbopen() ? I think I might have messed up with these values causing these errors.

SQL Server Connection Issue

$
0
0

I've tried going through the steps to resolve the issue, but I am still coming up blank. The part that I am not understanding is the, "A non-recoverable error occurred during a database lookup." part. Is this a security problem? I can establish an ODBC connection to the server as well as connect and query through visual studio, however when trying to run it through one of our custom programs, it throws this error message. 

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 0 - A non-recoverable error occurred during a database lookup.)


UPDATE statement Query Timeout

$
0
0

I am performing a UPDATE T-SQL statement from my vb.net program against my SQL2008R2 database and I am getting a Query Timeout error message after 30 seconds. 

When I perform the statement directly on the server it is successful but takes 1:14 seconds.

On my server the following settings are set:
Server Properties/Connections
Allow remote connections to this server. (X)
Remote query timeout =0

Server Properties/Advanced
Remote Login Timeout = 0
Query Wait =0

My ConnectioString used in my vb.net is this:
ConnectString = "Provider=" & mstrProvider & ";" & _
                         "Persist Security Info= True" & ";" & _
                         "OLE DB Services = -2" & ";" & _
                         "User ID=MYUSER" & ";" & _
                         "Password=" & mstrPassword & ";" & _
                         "Initial Catalog=" & mstrDataSource & ";" & _
                         "Query Wait=-1;" & _
                         "Data Source=" & goSQLDataSource

I have changed the Query Wait from 0 to -1, to 300 with effect.

Does anyone know where this time 30 second timeout might be coming from?

Thanks in advance

Accessing MS SQL DB through firewall

$
0
0

Hi,

Our organisation has some strict firewall infrastructure in place that prevents us from accessing MS SQL databases from our desktops.  In the Oracle world, we have to aceess those databases via a TNS Proxy set-up.  However, our IT guys don't know how to facilitate the same access for SQL Server DBs.

I apologie that I don't understand enough about the firewall technology to provide details on it, but I was hoping someone might be familiar enough with these sorts of situations that they might be able to propvide advice on how we can configure things to ensure we can access these databases from our desktops?

I'm not sure if it's relevant, but our Windows servers containign the SQL Server databases are on virtualised Linux environments.

Is anyone aware of TNS Proxy equivalient for SQL Server?

Any help appreciated.

Regards

Mick

How to get names of databases,tables and storedprocedures in a sql server instance?

$
0
0

Hi,

        I'm newbie of MS SQL Server 2008. Since that, I'm struggling for gettiing names of databases, tables and stored procedures in a sql server instance. If any one help me, it will be very supporting for my ongoing process.

        Thanks in advance!!!

I have a table with the following columns as in the following:

$
0
0

I have a table with the following columns as in the following:

CREATETABLE [dbo].[TimeLogging](

      [ID] [int]NOTNULL,

      [Date] [date]NULL,

      [timelogged] [decimal](18, 2)NULL,

      [username] [varchar](50)NULL,

 CONSTRAINT [PK_TimeLogging]PRIMARYKEY CLUSTERED

(

      [ID]ASC

)WITH(PAD_INDEX =OFF,STATISTICS_NORECOMPUTE  =OFF, IGNORE_DUP_KEY= OFF,ALLOW_ROW_LOCKS =ON,ALLOW_PAGE_LOCKS  =ON) ON [PRIMARY]

)ON [PRIMARY]

I have data something as in the following:

ID     Date     timelogged     username
1     2012-10-08     5.50     Ravi
2     2012-11-08     2.30     Ravi
3     2012-10-08     3.30     Joe
4     2012-11-08     7.30     Joe
5     2012-11-09     8.30     Marie
6     2012-12-05     99.90     John
7     2009-06-09     78.78     Kelly

I want this data to be displayed with all the user names as columns in the results with a unique date displayed in each row and show the total on each row and column. The output should be as in the following: and i also want to display recored b/w two date
Date     Ravi     Marie     Kelly     John     Joe     Total
06/09/2009     0.00     0.00     78.78     0.00     0.00     78.78
10/08/2012     5.50     0.00     0.00     0.00     3.30     8.80
11/08/2012     2.30     0.00     0.00     0.00     7.30     9.60
11/09/2012     0.00     8.30     0.00     0.00     0.00     8.30
12/05/2012     0.00     0.00     0.00     99.90     0.00     99.90
Total     78.78     8.30     78.78     99.90     10.60     205.38

please help me

Querying Active Directory

$
0
0

Need help understanding error message from CLR:

I encapsulated calls to Active Directory in a dll.  This dll works very well for a call or a few calls.  However when I wrote a winapp that calls many times repeatedly to this dll and consequently to DirectorySearcher, I recieve the following message after many iterations have been made:  (while debugging, or in release mode same problem occurs)

 

Managed Debugging Assistant 'ContextSwitchDeadlock' has detected a problem in 'D:\DevProjects\ADQuery\SysRegLoadPersGrps\SRLoadPersGrps\SRLoadPersGrps\bin\Release\SRLoadPersGrps.vshost.exe'.
Additional Information: The CLR has been unable to transition from COM context 0x1a0998 to COM context 0x1a0b08 for 60 seconds. The thread that owns the destination context/apartment is most likely either doing a non pumping wait or processing a very long running operation without pumping Windows messages. This situation generally has a negative performance impact and may even lead to the application becoming non responsive or memory usage accumulating continually over time. To avoid this problem, all single threaded apartment (STA) threads should use pumping wait primitives (such as CoWaitForMultipleHandles) and routinely pump messages during long running operations.


Continue  & breakAll after the above error thrown caused this system error code to be generated:  H80131c25

 

Here's one of the subs in the dll that is causing the problem. After multiple calls to the directorySearcher, one or another call fails with the above error.  (on the FindOne method here, but on the .GetDirectoryEntry method in another sub, random which one fails, it's the number of iterations that is the problem)   Question I have is:  Is the only way to stop this error to reduce or slow down the calls to DirectorySearcher?
 

 Private Sub GetGroupName(ByVal GroupName As String, ByRef strDistinguishedName As String, ByRef strMsg As String)
        Dim strFilter As String
        Dim entry As DirectoryEntry
        Try
            strFilter = "(&(objectClass=group)(cn=" + GroupName + "))"
            Dim myArr() As String = {"distinguishedName"}
            Dim mysearchroot As DirectoryEntry = New DirectoryEntry(myLDAPPath)
            Dim myDirectorySearcher As New DirectorySearcher(mysearchroot, strFilter, myArr, SearchScope.Subtree)
            Dim mySearchResult As SearchResult = myDirectorySearcher.FindOne
            If mySearchResult Is Nothing Then
                Throw New Exception("Get Group Name: No groups by name: " & GroupName)
            End If
            entry = mySearchResult.GetDirectoryEntry()
            strDistinguishedName = entry.Properties.Item("distinguishedName").Value.ToString
            'cleanup
            entry = Nothing
            mySearchResult = Nothing
            myDirectorySearcher.Dispose()
            mySearchResult = Nothing
        Catch e As Exception
            strMsg = "Failed to Get Distinguished Group Name for: " + GroupName + " " + e.Message
            strDistinguishedName = ""
        End Try

    End Sub


 

 

Viewing all 4164 articles
Browse latest View live


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