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

Transação distribuida no SQL Server

$
0
0

Boas!!

Sou iniciante em banco de dados e estou com uma duvida. Tenho uma integração para fazer com outra base de dados (pra ser específico é o OpenEdge Progress), e para fazer a integração entre SQL Server x Progress estou usando LInkedServer.

Para fazer um select ou insert, faço a seguinte instrução:

INSERT OPENQUERY("linked-banco", 'SELECT id FROM PUB."tabela" ') VALUES (4)

Fazendo via comando eu consigo normalmente. Só que eu necessito fazer isso via TRIGGER. Se eu montar uma trigger com essa instrução ele retorna um erro dizendo:

"The operation could not be performed because OLE DB provider "MSDASQL" for linked server "linked-banco" was unable to begin a distributed transaction."

Alguem pode me ajudar se há alguma forma de eu "desativar" essa transação distribuida, ou conseguir passar isso?

att

Rafael


Duda general C#

$
0
0

Buenas, estoy haciendo un programa simple en C# que utilizaría en la empresa para hacer consultas en SQL Server y al dar click en "consultar" muestre los resultados. La complicación es que el query depende de lo que quiere consultar el usuario, para ser más claro dejo el código:

#region CNX STRING
                    cnx.Open();
                    string query = "SELECT " + comboBoxDato.SelectedItem.ToString() +
                           " FROM " + comboBoxBase.SelectedItem.ToString() +
                           " WHERE letra='" + textBoxLetra.Text +
                           "' and " + comboBoxDatoDesc.SelectedItem.ToString() +
                           "='" + textBoxValDato.Text + "'";
                    SqlCommand cmd = new SqlCommand(query, cnx);
                    cmd.ExecuteNonQuery();
                    cnx.Close();
                    #endregion

Se me complica cuando tengo que mostrar el resultado en la DataGridView, probé de muchas maneras, ninguna dio resultados. Espero su pronta ayuda!

writing data to the same table from several sources in parallel

$
0
0

Hello,

a vbscript reads out the eventlog of a server and writes the data into a sql dtabase:

Set objConn = CreateObject("ADODB.Connection")
Set objRS = CreateObject("ADODB.Recordset")

strSQLStmt = "SELECT * FROM tbl_eventlog"
strConn = "Provider=SQLOLEDB;server=srv001;uid=sqluser;pwd=password;Initial Catalog=DB-Eventlog;"
objConn.Open strConn
objRS.CursorType = adOpenKeyset
objRS.Open strSQLStmt, strConn, 3, 3

strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_NTLogEvent WHERE  LogFile <> 'Security'")

 For Each objItem In colItems

	objRS.AddNew
	      objRS.Fields("RecordNumber").Value = objItem.RecordNumber
	      objRS.Fields("Logfile").Value = objItem.Logfile
	      objRS.Fields("ComputerName").Value = objItem.ComputerName
	      objRS.Fields("EventCode").Value = objItem.EventCode
	      objRS.Fields("Message").Value = objItem.Message
	      objRS.Fields("SourceName").Value = objItem.SourceName
	      objRS.Fields("TimeGenerated").Value = objItem.TimeGenerated
	      objRS.Fields("Type").Value = objItem.Type
	      objRS.Fields("User").Value = objItem.User
	objRS.Update
Next

objRS.Close

When I start the script at several servers one after the other it works as it should so far. But if the script has been started via scheduled tasks at the same time data won't be written to the table.

How can I achieve that data is written in parallel?

Thanks in advance

Torsten

Do you have link for Microsoft ODBC Driver for SQL Server on Linux for 32 bit

$
0
0

Hi  All,

I am looking for Microsoft ODBC Driver for SQL Server on Linux with 32 bit and i don't see any link for it. Can you please let me know any link for it and whether microsoft is supporting for 32 bit msodbc  driver.

Thanks in advance ..

Thanks

VenkataKrishna

link server error

$
0
0

Hi,

 

I have one situation here, when ever this particular query is executed through linked server, the server hangs.The services get restarted.

 

In the error log, I got a stack dump error.

 

Query :

select*

--INTO #OMNIRELATIONSHIPS

fromopenquery(BRTOOMNI,'Select a.CUST_ID,c.LASTEXIT_DEDUPE,c.apprefno as APPREF, a.firstname AS FIRST_NAME,a.midname AS MIDDLE_NAME,a.lastname  as LAST_NAME,

--a.ShortName Short_Name,

 a.DATEOF_BIRTH Contact_DOB,

 -- '''' as Contact_Status,

 a.ENTITY_TYPE As Contact_Type,

a.SEX Gender, a.MARITAL Marital_Status, a.bank_name1 Bank_Account_1, a.bank_name2 Bank_Account_2,

a.PANno PAN,b.ADDR_MOBILENO MOBILE,b.ADDR_PH1_NO As Res_Phone,b.ADDR_PH2_NO As Off_Phone,b.addr_ph1_no As Phone_1,

b.addr_ph2_no As Phone_2,'''' As Phone_3,'''' As Phone_4, '''' As Phone_5,b.ADDR_EMAILID Email,

b.ADDR_FIRSTLINE Address_Line_1,b.ADDR_SECONDLINE Address_Line_2,

b.addr_thirdline As Locality,  b.ADDR_CITY CITY,'''' District,b.ADDR_STATE STATE,b.ADDR_ZIPCODE ZIP_CODE,

b.ADDR_COUNTRY_DESC Country,'''' As Alt_Address_Line_1, '''' As Alt_Address_Line_2,   

'''' as Alt_Mobile, '''' As Alt_Off_Phone, '''' as Alt_Res_Phone,'''' As Alt_Email, b.ADDR_LANDMARK LANDMARK,     

'''' As Contact_Owner

--'''' As ContactOwnerID,'''' As Status_Code,'''' As Layout

From hlbp_exttable c, SLBP_ENTITY a, (select * from slbp_addr@uat2rpt where addr_type = ''CURRENT RESIDENCE'') b --,punit_appref e        

Where c.customer = a.record_id and a.record_id = b.addr_parentid

AND trunc(c.LASTEXIT_DEDUPE)=trunc(sysdate-1)

--nd c.apprefno = e.appref

--and c.apprefno = ''13297840''

and a.CUST_ID is not null')

 

The 3 tables given in the query has data on around 22 lakhs to 1 crore.

 

Cannot connect from windows 7 to a sql server 2008 R2 instances running in a windows 2008 r2 via Static IP

$
0
0

We have an SQL 2008 R2 running in a windows 2008 R2 Server with a static IP but we are unable to connect to this server from a particular windows 7 32 bit client machine.

But we can very well successfully connect to this server from other machines running win XPs and win7s

Is there any settings specifically in win7 that should be configured ?

or is there any modem settings ?

What all way should we attempt to get this right ?

Its very urgernt and hope someone will answer it soon

Thanks in advance


Store the Job History in Text File

$
0
0

Hi

I have a SQL Job on PROD Server. I don't have access to PROD Server hence I am thinking of putting the daily SQL Job History in the Text File as Log / Trace.

What can be done in order to catch the Job History in Text File or so ?

Any Ideas ??

 

Thanks!!

Why ODBC connection to SQL Server on Virtual Machine failed?

$
0
0

I have Windows 8 workstation virtual machine running Windows Server 2008R2 and SQL Server 2008R.
IP of Virtual machine is 10.10.0.9. I can succesfully ping it from workstation.
I have created SQL account "test". I have tested that I can login to studio with this account. SQL Server instance name is "Lion".
I have not done any specific configuration in SQL Server.
I turned off all Windows Firewall on Windows 8 for testing purpose. Firewall on server is off too.

I have now create ODBC connection in Windows 8.
-Server name is "10.10.0.9".
-Authentication is SQL login with "test"
-Default settings with other configuration

Then I clicked "Test Data Source" and error occured. Why?

Microsoft SQL Server Native Client Version 11.00.2218

Running connectivity tests...

Attempting connection
[Microsoft][SQL Server Native Client 11.0]Named Pipes Provider: Could not open a connection to SQL Server [1326].
[Microsoft][SQL Server Native Client 11.0]Login timeout expired
[Microsoft][SQL Server Native Client 11.0]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!


Kenny_I



BCP query

$
0
0

Hi ,

Am running the below bcp command to transfer data from one to another table.

it is running succesfuully but the target table has no records.

exec

xp_cmdshell'bcp "select * from table1" queryout "Table2" -N -S localhost -T -E'

Max login/logout for sql user but not for windows user?

$
0
0

We are migrating from 1 server 2003 iis6 + sql 2000 to 2 server with server 2003 iis 6 and server 2008 R2 with sql 2012 so only the sql server moves ...

We are facing a problem. We use an old connection string oledb with uid/pass.
This works fine until we do about 1000 login/logouts within 1 minute.
(then we get an acces denied)
With the use of an windows account we don't have this problem but with a sql user we do.
(turning off firewall doesn't help)
We tried alot of properties on the sql 2012 server but nothing seems to help.

Is there a way to increase the possible number of login/logouts for an sql user??
Remark : we don't want to change anything on the 2003 IIS6 server





SQLSRV for 64bit PHP: now that there is an official x64 release, when can we start connecting to sql server?

$
0
0

Now that there has been a 64bit release from the official PHP source, is there a 64bit sqlsrv driver?
If not quite yet, what's the lead time?

$0.02: As a little side note, ahuge portion of web dev's on a MS OS run WAMPSERVER, which has had a 64bit version foryears now.  Personally, I've steered projects away from MS DB solutions countless times just to avoid the hassle of rebuilding my dev env ... and I have no delusions about being something special ... ifI'm doing it, surely there are countless other dev's out there doing the same:)    I've always found it ironic that I can only use a MS storage product from mynon-MS OS's.

Anyhow ... back to the topic at hand.
Although the first release of php64 from the official source is for v5.5, please consider that many dev's have many projects in other (older) versions. Personally, I've got plenty of code base in 5.4.

A speedy reply would be greatly appreciated.
I have a project on the block right now, and MS sqlsrv is the requested DB.
If I don't need to worry about steering this one away from MS sql server too, that'd be nice ... just one less thing on my hit list.

connect to existing database in VS 2012

$
0
0

I have a project in VS 2010 that connects to a SQL Database. I have moved my sql files and project to a laptop. In VS 2012 you can create a database by going to the SQL Server Object Explorer and right clicking "DataBases" and click "Add New DataBase", there is no option to connect to an existing database.

In my instance I need to connect to a database that already exists. How do I do that?

Error on Open command using SQLConnection

$
0
0

Hi people,

I got two Vb.Net applications that connects to the exact same server, using the exact same code, just in different Data Bases... I use a Connection String like this:
"Data Source=xx.xxx.xx.xxx;Initial Catalog=ibptax;Persist Security Info=True;User ID=sa;Password=xxxxx"
(obs.: I'm using 'sa' user to guarantee that is not an user access problem)

In the vc.Net code I use:
        Dim con As New System.Data.SqlClient.SqlConnection
        con.ConnectionString = strConex
        con.Open()

this way, in the first Application, works very fine...

For some reason that I can't understand, in the second application I got the exact same code, doing the exact same thing, to the exact same SQL Server, only another DataBase, both applications using "sa" user, but it doesn't work...
Using my proxy to collect what is going out of my machine, in the second application when execute con.Open the application tries to do something using 445 port and the server than returns error...

Somebody knows what It can be?

Error above:

System.Data.SqlClient.SqlException (0x80131904): Erro de rede ou específico à instância ao estabelecer conexão com o SQL Server. O servidor não foi encontrado ou não estava acessível. Verifique se o nome da instância está correto e se o SQL Server está configurado para permitir conexões remotas. (provider: Named Pipes Provider, error: 40 - Não foi possível abrir uma conexão com o SQL Server) ---> System.ComponentModel.Win32Exception (0x80004005): O caminho da rede não foi encontrado     em System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)     em System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)     em System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, Boolean withFailover)   
 em System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, Boolean withFailover)     em System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer timeout)     em System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance)     em System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions)     em System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)     em System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions)     em System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnectionOptions userOptions)     em System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnectionOptions userOptions)     em System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)     em System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)     em System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)     em System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)     em System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)     em System.Data.SqlClient.SqlConnection.Open()     em Gerente_2012_Cloud_GerenciamentoDeMasters.utils.AbrirDataTable(String sql) na D:\_Trabalho_ParanaSoftware\Gerente 2012 Cloud_GerenciamentoDeMasters\Gerente 2012 Cloud_GerenciamentoDeMasters\utils.vb:linha 627     em Gerente_2012_Cloud_GerenciamentoDeMasters.utils.ControleDeAcessoPrincipalViaRegistro() na D:\_Trabalho_ParanaSoftware\Gerente 2012 Cloud_GerenciamentoDeMasters\Gerente 2012 Cloud_GerenciamentoDeMasters\utils.vb:linha 1096  ClientConnectionId:00000000-0000-0000-0000-000000000000

How to install JDBC driver Microsoft sqljdbc.jar in tomcat 7

$
0
0

I want to know if it is possible to use this JDBC driver with Tomcat 7.

If so, how do I input the server.xml, web.xml(WEB-INF), and context.xml(WEB-INF) ?

Here is my context.xml...

<Context>
  <Resource name="jdbc/Contacts"
            auth="Container"
            type="javax.sql.DataSource"
            username="E-Mail Address"
            password="Last Name"
            driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver"
            url="jdbc:sqlserver://localhost;DatabaseName=mydb;SelectMethod=cursor;"
            maxActive="8"
            />
</Context>

Here is what I have in my web.xml .

   <security-constraint>
      <display-name>My First Application Security Constraint</display-name>
      <web-resource-collection>
         <web-resource-name>First App Protected Area</web-resource-name>
         <!-- Define the context-relative URL(s) to be protected -->
         <url-pattern>/jsp/security/protected/*</url-pattern>
         <!-- If you list http methods, only those methods are protected -->
         <http-method>DELETE</http-method>
         <http-method>GET</http-method>
         <http-method>POST</http-method>
         <http-method>PUT</http-method>
      </web-resource-collection>
      <auth-constraint>
         <!-- Anyone with one of the listed roles may access this area -->
         <role-name>somename</role-name>
         <role-name>role1</role-name>
      </auth-constraint>
    </security-constraint>

    <!-- Default login configuration uses form-based authentication -->
    <login-config>
      <auth-method>FORM</auth-method>
      <realm-name>Example Form-Based Authentication Area</realm-name>
      <form-login-config>
        <form-login-page>/jsp/security/protected/login.jsp</form-login-page>
        <form-error-page>/jsp/security/protected/error.jsp</form-error-page>
      </form-login-config>
    </login-config>
       
    <!-- Security roles referenced by this web application -->
    <security-role>
      <role-name>role1</role-name>
    </security-role>
    <security-role>
      <role-name>somename</role-name>
    </security-role>

I assume something must be put in the server.xml but im not sure what.

Here is what I have....

      <Realm className="org.apache.catalina.realm.LockOutRealm">
        <!-- This Realm uses the UserDatabase configured in the global JNDI
             resources under the key "UserDatabase".  Any edits
             that are performed against this UserDatabase are immediately
             available for use by the Realm.  -->
        <!-- <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
               resourceName="UserDatabase"/> -->
         <Realm className="org.apache.catalina.realm.DataSourceRealm"
  dataSourceName="jdbc/Pubs"
  userRoleTable="RolesTable" roleNameCol="Role Name"/>
         userTable="Contacts" userNameCol="E-mail Address" userCredCol="Last Name"/>
      </Realm>

What am I missing??? I have placed the sqljdbc.jar file in the tomcat/lib directory. Tomcat accepts

the file by starting the application. I am using form based authentication. I have basically used the

tomcat form example which includes other stuff that needs to be used to authenticate the app. If you

look at the web.xml you can see that access to the app will only take place by accessing the login

form. Then it will access any form on the web app. The form continually loops if it does not find an

entry or even if the db is not working.


Adrian Aguinaga

param values in .asmx webservice

$
0
0

I have webservice web.asmx .

1) I wanna to add some Parameters at run time, but I am not getting how to do(give path). solution please..

And to get Param Value I am using :

2)HttpContext.Current.Request.QueryString["ID"].toString();   is this correct ?



SQLOLEDB and SQL Server 2014

$
0
0

I know that the Microsoft OLE DB Provider for SQL Server (SQLOLEDB) has been deprecated,
but I would like to understand if the new incoming SQL Server 2014 will yet allow to create connections using SQLOLEDB.

I expect that new feature will be not supported, but may existing legacy applications continue to access to database created on SQL Server 2014 using old schema ?
Do you know if SQLOLEDB will be removed on new server OS or we may continue to use/install it ?

Thanks in advance.
Maurizio


Max login/logout from 2003 server for sql user but not for windows user?

$
0
0

We are migrating from 1 server 2003 iis6 + sql 2000 to 2 server with server 2003 iis 6 and server 2008 R2 with sql 2012 so only the sql server moves ...

We are facing a problem. We use an old connection string oledb with uid/pass.
This works fine until we do about 1000 login/logouts within 1 minute.
(then we get an acces denied)
With the use of an windows account we don't have this problem but with a sql user we do.
(turning off firewall doesn't help)
We tried alot of properties on the sql 2012 server but nothing seems to help.

Is there a way to increase the possible number of login/logouts for an sql user??
Remark : we don't want to change anything on the 2003 IIS6 server

edit : problem occurs only from 2003 server






SQL server error password mismatch sometimes

$
0
0

We have an application that connects to a MSSQL 2005 database using a generic login.  On 64bit Windows 7 machines users get a series of 'can't connect to database' errors after a period of inactivity in the software, usually around 15 minutes or so.  If they cancel the program and log back in it always connects and works fine (unless they are inactive for awhile again).  On the server we are seeing the "Error: 18456, Severity: 14, State 8" error in the logs which indicates a password mismatch but as I noted above, if the user cancels the program and logs back in, using the same credentials, it connects just fine.  This does not happen on WinXP or 32bit Win7 machines.  Any help would be greatly appreciated.

SQL Server Data Tool : SQK71501 Procedure contains an unresolved reference to an object.

$
0
0

Hi there,

From VS2012 I created a Database project and import scripts from local PC. When I built project, I got the following compiling errors:

*******************************************************************************************************

Error 198 SQL71501: Procedure: [dbo].[GetReportHistory2] contains an unresolved reference to an object. Either the object does not exist or the reference is ambiguous because it could refer to any of the following objects: [dbo].[ReportHistory].[LastName] or [dbo].[UserProfile].[LastName]. C:\MyProjects\DatabaseProject\Database.SQL.WithData\dbo\Stored Procedures\GetReportHistory2.sql 79 4 Database.SQL.WithData

*******************************************************************************************************

When I tried to create and import on some other PCs, everything works well.

How to solve the above problem?

Thank you very much in advance for your support.

Anna

compare xml file

$
0
0

hi

i have 2 xml file below like:

<root><Name>toni</Name><age>20</age><Tel><num1>7777</num1><num2>8888</num2></Tel></root>

-------------xml2---------
<root><Name>toni</Name><age>20</age><Tel><num1>7777</num1><num2>1111</num2></Tel></root>

now i want find diff nodes between them

for example for upper

diff is node num2

please help me for create query

thanks

Viewing all 4164 articles
Browse latest View live


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