Problem Converting C Application From Using DBLIB Bcp To Using ODBC Bcp.
May 4, 2007
I have an application that was converted from using DBLIB bcp to using ODBC bcp. All other field/data types bind are updated correctly, but dates put in the date
1753-01-01 00:00:00.000 when it should be NULL. The variable is a char [24] and the first item is set to ( dbLoanBankruptcy.MotionforReliefReqDate[0] = NullChar; ).
Is there any example or way to put the date in as null when the variable is null and an actual date as needed?
We migrated one database from SQL Server 6.5 to 7.0. One of our applications connects to SQL Server using ODBC driver.
We created a new driver pointing on our new server,we can write and execute most of the queries that don't return a big RecordCount. As soon as we try to execute a query that should return more then 125-140 rows, the process fails returning an 'Interface Error' error message.
When we tested same queries pointing to the old (SQL Server 6.5) box, they worked fine.
We upgraded our ODBC ActiveX to a newer version, it allows us to get a few more rows only.
I am currently modifying an existing application (which uses OLE DB Consumer Templates to access a remote SQL db) to utilize SQL Native Client instead. Does anyone have any experience making this change? Am I correct in my assumption that all I have to do is: change my included headers from 'sqloledb.h' to 'sqlncli.h' and change CLSID_SQLOLEDB to CLSID_SQLNCLI? I am still including the 'atldbcli.h' header and therefore still using the OLE DB Consumer Templates. Can I continue to use the Consumer Templates along with SQL Native Client?
who still uses the old dblib can help me? thanks in advance:
1.create table & procedure in db: test_table(uniqueidentifier a,varbinary50 b) CREATE PROCEDURE insert_table @b_in varbinary AS insert into test_table(b) values (@b_in) GO
2.write program use dblib: wchar_t str[120]=L"ABC"; dbrpcparam(dbproc[i], "@b_in", (BYTE)NULL, SQLVARBINARY, -1, 6, &str)
3.I can find the program executed successfully,but only 1 Byte is inserted: a b ----------------------------------------------- 199D71BE-327A-4BC1-AEC8-ACB0C96076CA 0x41
We currently have a C++ application thats uses DBLib to insert data from a socket conection into a SQL 2005 Database.
The data from the socket is Real time Market Quotes (Ticks) and it the application takes the quote messages, formats them and inserts them in to the Database via DBlib Bulk API, and batching the insert at 1000 messages / sec.
As any in the financial industry knows, the message rates have expoloded over the past year and they keep inceasing, DBLIB has always been the Highest Performing way to get these Quotes ticks into the Database fast.
I house testing has show that DBLIB does top out (for us) at arround 15,000 messages per second which under a market swing can excede 20,000 / sec. This then leads us ot a queueing situation (Application Queue) till the traffic slows and the Applicaiton can flush all the data to the Database. We get arround this DBLIb limitation by splitting the insert duty to more them on process where each process's DBLIB connection has that 15,000 message celiing.
This application does only inserts to a table, no updates or deletes, every tick is a row.
The Question... With DBlib being Depricated through 2000 and 2005 we now would like to redue the application with a more supported interface to SQL Server. I am researching the SQL 2005 Native client API's and I am looking for which method the SQL Native Client (ODBC) or the SQL Native Client (OLE DB) are the close cousin to the old DBlib to do this type of Real time Bulk operation?
I am developing an ETL system on a 32-bit machine let's say, called 'dwdev'. The application connects to a Sybase database as a source system using ODBC connection. I am able to run this application directly from Visual studio 2005 and i am able to deploy it into SQL Server 2005 and run it from Server as a job. Both work. At this server i am connecting to a SQL Server instance called 'dwdev'.
When i transfer my application onto a 64-bit machine, let's say called 'dwtest', i am able to run my application from Visual Studio 2005 properly and it works, but when i deploy it into SQL Server (instance is called 'dwtest') and try to run it as a job just like the development machine, it gives an error and stops executing.
I was facing 'data source' type of error when i was first trying it from Visual Studio, but i solved this problem by setting Run64bitRunTime settings to FALSE on the Project's properties Debugging Page, at 64-bit machine. now it uses 32-bit runtime then 32-bit Sybase ODBC driver. But i cannot force the application to use 32 bit runtime when i am executing it from SQL Server as a job.
How can i do that? is there an alternative method?
I've developed an application that connects to a SQL Server 2005 Express database. I created a DSN to connect to the database through ODBC. Currently, I am testing locally and everything works fine.
I would now like to install my application on another workstation and connect remotely to the database located on my development machine.
The client workstation does not have SQL Server 2005 Express installed on it because I would just like my application to connect remotely by creating the DSN and using ODBC. What I'm missing here are the database drivers. The "SQL Natice Client" is not available on this client workstation. How can I deploy the necessary drivers with my installation file so that I may create the required DSN name using the SQL Native Client driver?
I am using SSIS 2014 with the below .net framework version and installed in Windows server 2012 R2 . I have installed my client's odbc drivers (both 32 bit and 64 bit) in my production server and created ODBC system DSNs for 32 bit and 64 bit.
When i open SSIS 2014 and tried to create the odbc connection but i can able to see only the 32 bit system DSN connection ,i can't able to see my 64 bit odbc system dsn connection.
Microsoft Visual Studio 2012 Shell (Integrated) Version 11.0.50727.1 RTMREL Microsoft .NET Framework Version 4.5.51650
SQL Server Integration Services   Microsoft SQL Server Integration Services Designer Version 12.0.1524.0
And i installed my client odbc drivers(32,64 bit) and created ODBC system DSNs in my local system and when i open ssis 2014 and i can able to see both the ODBC system DSNS(32,64) connections from SSIS ODBC connection.
I am using below version of .net framework in my local system which was installed in windows 7 and i have SSIS 2012 also installed in my system and i can able to see both ODBC connections using 2012 as well in my local system.
Microsoft Visual Studio 2012 Shell (Integrated) Version 11.0.50727.1 RTMREL Microsoft .NET Framework Version 4.5.50938
SQL Server Integration Services   Microsoft SQL Server Integration Services Designer Version 12.0.1524.0
why i can not see the ODBC 64 bit system DSN connection from SSIS in my production server ?
I am using VB.NET 2005 and set up an ODBC connection via ODBC.ODBCConnection to a MDB database. Therefor, I use the "Microsoft Access ODBC Driver (*.mdb)".
When I set up a ODBCCommand like "ALTER DATABASE..." or "CREATE TABLE..." and issue it with the com.ExecuteNonQuery() command, I get an error from ODBC driver, that a SQL statement has to begin with SELECT, INSERT, UPDATE or DELETE.
How can I use DDL statements via ODBC?
I would appreciate if you could help me to use ODBC for that - no OLE, no ADO.
have SQL Server 2005 std edition SP1 installed on Windows 2003 Std edition .Configured Transactional (single Publisher and no clustered environment.) Replication past two months working fine, Now 1.Distrib.exe application err is coming.
Due to which my job is failing (Distributor to Subscriber). Iam attaching thw file. Thanks Sandeep
I apologize if this is not the correct forum for this posting. Looking at the descriptions, it appeared to be the best choice.
I am running Windows XP Pro SP2. I have installed the SQL Native Client for XP. However, when I try to add a new data source through ODBC Connection Manager, SQL Native Client is not listed as an option. I have followed this procedure on three other systems with no problems. What would be causing the SQL Native Client to not show up in the list of available ODBC data sources?
Hi all,I am having trouble getting linked Oracle 9 server in MS SQL Server2005 Express to work properly. My machine is running Windows XP.The Microsoft and Oracle OLE DB Providers have problems dealing withOracle's Numeric Data Type, so I decided to use Microsoft's OLE DB forODBC Provider and an Oracle ODBC source. When using the Microsoft ODBCfor Oracle Driver in my ODBC source I have inconsistent behavior.Sometimes my queries are processed properly, then other times I get thefollowing errorOLE DB provider "MSDASQL" for linked server "ODBCBEAST" returnedmessage "[Microsoft][ODBC Driver Manager] Driver's SQLSetConnectAttrfailed".OLE DB provider "MSDASQL" for linked server "ODBCBEAST" returnedmessage "[Microsoft][ODBC Driver Manager] Driver's SQLSetConnectAttrfailed".OLE DB provider "MSDASQL" for linked server "ODBCBEAST" returnedmessage "[Microsoft][ODBC driver for Oracle][Oracle]".Msg 7303, Level 16, State 1, Line 1Cannot initialize the data source object of OLE DB provider "MSDASQL"for linked server "ODBCBEAST".I have no idea why sometimes I can connect to the linked server with noproblems andwhy other times it performs like this. I'm not changing anything aboutthe system I can think of. When I use an Oracle client (PL/SQL) I haveabsolutely no problems connecting. TNSPING returns that the connectionis good.This is unacceptable so I decided to try my luck with the Oracle 10gODBC driver. However when I use this and perform an openquery selectagainst the linked server I get back only 11 rows, when I know that thedatabase has over 100 rows (in fact when using the Microsoft ODBCdriver and it works that's what I get). I figured maybe the buffersetting needed to be raised in the ODBC configuration so I took it from64000 to 600000 (a magnitude of 10) but I still get back only 11 rows.I'm at my wit's end.Any suggestions on resolving one or the other problem would be muchappreciated.Thanks much
Please help share with me if you know the version compatibility matrix of Ms SQL Server, ODBC driver (sqlsrv32.dll), Driver Manager (odbc32.dll) and ODBC API spec. For instance, how can I know Ms SQL Server 2000 can work with which version of sqlsrv32.dll, a particular version of sqlsrv32.dll can work with which version of odbc32.dll and a certain version of sqlsrv32.dll/odbc32.dll conforms to which version of ODBC API spec (e.g. 3.5).
On localhost this application works fine but when I put on remote server. I am getting following errors. For both localhost and server, I am using same remote sql 2000. I will appreciate any help.
Thanks,
Arif
Server Error in '/' Application. --------------------------------------------------------------------------------
ERROR [42000] [Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorrect syntax near ')'. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: Microsoft.Data.Odbc.OdbcException: ERROR [42000] [Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorrect syntax near ')'.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Hey, don't know if it's the right place for this question but i hope you help me. I made an application with VS 2005 that connecting to sql server file db.mdf Now i want this application work on another user computer, and of course i don't want to install vs 2005 there. I did install .net framework, but what i need to do to make the database work? do i have to install sql server on his computer? or is there something more simple? I know that if i was using access file than i need to install nothing else. please help! thanx. max
I have a select statement like this: select IsVerified from AppForm the IsVerified returns 'True' ...can I convert that value to 'Yes' by using some sort of function?
ok i am very very new at this, ive downloaded the SQL 2005 trial and i can not seem to figure this out. I have a .xls i want to make a active sql page out of. please please help me with this
the .xls is here http://www.mediafire.com/?5jtgzcxb232
Once a week there is a sqlscript, which should run and store data to a txt file.
There is a tablle in which imagedata is stored in RAW format(that one with small boxes, Qmarks and dots...).
Now i want to export it to the txtfile as HEX, so i can decode it by php further.
With the thumbnail, also stores there everything is fine, the SQL looks that way:
SELECt hex(thumbnail) FROM picTable where id_pic=54985
The Data is then displayed as HEX. But the standart picture is to big. When i use the statement: SELECt hex(bigpic) FROM picTable where id_pic=54985
i got the error message:
An error occurred while running the query.
The data type, length, or value of argument 1 of HEX is invalid.
(SQL code = -171, SQL state = 42815)
After some research i found that the maximum lenght is 16 336 bytes for the HEX-operation. The picture is nearly 30 000 bytes... :shocked: Have anyone an idea how to fix that? I am not able here to accsess to the database direct...
Hi All, I am in the process of changing the cursor based Proc with temp tables, I have one of the Procs which is beening used to get a value for the cursor, I am thinking if it is possible to change it to a function so that I can update the column at once.
[code] CREATE PROCEDURE[dbo].[get_cre_tijd_id] ( @tijd_datum datetime, @tijd_id int output ) AS
SET @datum_tekst = CAST(@tijd_datum AS VARCHAR); SET @datum_tijd = CONVERT(DATETIME, SUBTRING(@datum_tekst, 1, 12), 21 ) SET @tijd_id = (SELECT tijd_id FROM dim_tijd WHERE tijd_datum = @datum_tijd )
IF @tijd_id IS NULL BEGIN INSERT INTO dim_tijd ( tijd_datum , jaar , kwartaal , maand , dag , periode , week , weekdag ) VALUES ( @datum_tijd , datepart(yy,@tijd_datum) , datepart(q,@tijd_datum) , datepart(m,@tijd_datum) , datepart(d,@tijd_datum) , ceiling(datepart(wk,@tijd_datum)/4.00) ,dbo.get_iso_week(@tijd_datum) , datepart(dw,@tijd_datum) )
SET @tijd_id = (SELECT tijd_id FROM dim_tijd WHERE tijd_datum = @datum_tijd) END
I am subtracting two datetimes (last(fields!FaultStart.value))-(first(fields!FaultStart.value)) this works fine and returns a value in a textbox 5.23:44:23. I need to convert that number to minutes I am very new to sql programming and do not know very many commands. I am using Microsoft sql server 2005 express edition along with sql server business intelligence development studio where I placed a textbox and entered the expression above. I have also tried to use datediff command =datediff(second, (last(fields!FaultStart.value)),(first(fields!FaultStart.value))) but the second is underlined and tooltips says WRONG NUMBER OF ARGUMENTS I€™ve tried =datediff(€œsecond€?, (last(fields!FaultStart.value)),(first(fields!FaultStart.value))) and =datediff(€œ€™second€™€?, (last(fields!FaultStart.value)),(first(fields!FaultStart.value))) also for second I€™ve tried seconds. Any help would be most appreciated
I haven't seen a really good solution for this in amongst the threads about UTC. What I want to do is convert a date time to UTC, taking into account whether or not it is in DST, and be able to deploy this code to any server in the world without customizing the SQL code, and have it know how to convert, as long as a I feed it the local Time Zone.
I would think this would be easy because the OS knows at any given time what time zone has what UTC offset, and exactly at what time DST starts and ends. Right now I do this, but it is limited. I have a table that, for each site (there can be more than one site in different time zones) stores the UTC offset and whether or not the site observes DST. New York would have the "Observes_DST" set to 1, Phoenix would have it set to zero. The "Hours_To_UTC" value would be 5 for New York.
This code below assumes all sites are located in Canada or the US, as Canada and the US now use the second Sunday in March and first Sunday in November as the switch over times. (although this would work fine for countries like India and China that don't observe DST).
UPDATE a
SET Time_Arrived_UTC =
CASE
WHEN b.Observes_DST = 1 THEN
CASE
WHEN Month(Time_Arrived) IN (4,5,6,7,8,9,10) THEN
DATEADD(hh,b.Hours_From_UTC - 1,Time_Arrived)
WHEN Month(Time_Arrived) = 3 AND Day(Time_Arrived)- DATEPART(dw,Time_Arrived) >= 7 AND
Day(Time_Arrived) <= 14 AND DATEPART(dw,Time_Arrived) <> 1
then DATEADD(hh,b.Hours_From_UTC - 1,Time_Arrived)
WHEN Month(Time_Arrived) = 3 AND Day(Time_Arrived) > 14
then DATEADD(hh,b.Hours_From_UTC - 1,Time_Arrived)
WHEN Month(Time_Arrived) = 3 AND Day(Time_Arrived) >= 8 AND Day(Time_Arrived) <= 14 AND
DATEPART(dw,Time_Arrived) = 1 AND DATEPART(hh,Time_Arrived) >= 2
THEN DATEADD(hh,b.Hours_From_UTC - 1,Time_Arrived)
WHEN Month(Time_Arrived) = 11 AND Day(Time_Arrived) <= 7 AND DATEPART(dw,Time_Arrived) = 1 AND
DATEPART(hh,Time_Arrived) < 2 then DATEADD(hh,b.Hours_From_UTC - 1,Time_Arrived)
WHEN Month(Time_Arrived) = 11 AND Day(Time_Arrived)- DATEPART(dw,Time_Arrived) < 0 then
DATEADD(hh,b.Hours_From_UTC - 1,Time_Arrived)
ELSE DATEADD(hh,b.Hours_From_UTC,Time_Arrived)
END
ELSE DATEADD(hh,b.Hours_From_UTC,Time_Arrived)
END FROM
Facts_Table a INNER JOIN Site_Info_Lookup_Table b
ON a.Site_Name= b.Site_Name
This works, (and is much more efficient than using a UTC lookup table) and I could probably go about hard coding various other start and end DST datetimes for other time zone DST (Australia and Europe, for example), but that wouldn't be dynamic in case one country makes a change in policy that changes when DST starts and stops, like the US just did.
SQL Server only provides current time UTC conversion--I would think it should have a function like this:
ConvertToUTC(datetimevalue,timezone)
Oracle has a function like that, but it is useless because it doesn't take into account DST, it would for instance just add 5 hours to EST for every date you entered (now that's helpuful!). It is baffling that this function doesn't exist.
I am using Integration Services so I could probably build a script task that would query the OS for DST start and stop times given a particular time zone (if available), but I'm not much of a coder--would be nice to have an easy way to do it in Transact-SQL.
I'm needing to take a value inputted by a user via html form and convert it to a hex value upon inserting into SQL2000 db. I only need to store the 8 chars after "0x". Is there any T-SQL that can pull this off? CAST or CONVERT? Sorry if this is a silly question and hope I supplied enough info...
Hi I am converting data from old DB to NEW DBIn the OLD table fields like "PhoneNumber" the data enterd are [ 657 985-986, (03)-987-543, 675(89)00, ect]Is their any function in sql where I can get rid of all those spaces and () and - between the numbers as my new field is only numbers and with out spaceOtherwise I have to clean them up manually as I have 1000000 records cheers
I have a stored procedure which I user to retur an Email-address from aspnet_Membership (DB-table). Here is the code: ALTER PROCEDURE dbo.StoredProcedure2 @user nvarchar(256) AS DECLARE @id uniqueidentifier SET @id = '' SELECT @id = UserId from aspnet_Users WHERE UserName = @user SELECT Email From aspnet_Membership WHERE UserId = @id I use StoredProcedure2 in this way: Dim cmd As SqlCommand = New SqlCommand("StoredProcedure2", MyConnection) cmd.CommandType = CommandType.StoredProcedure 'send in UserName as @User to StoredProcedure2 cmd.Parameters.Add("@user", SqlDbType.NVarChar).Value = User.Identity.Name.ToString() 'Return EmailAddresse returnValue = cmd.ExecuteScalar() Message I get is: "Conversion failed when converting from a character string to uniqueidentifier" Please help...
Hi, I am developing a project that using the one of the starter kits which use the MS SQL EXPRESS database.The project is almost ready to be launch. few questions:
I am looking for a good host with good support reasonable paid. What is my options if I would like to convert from the current database, to other databases like MySql, MS SQL Server or any? which tools can help with this convertions? thats all, thanks.
I have an old table (table1) and a new table (table2). I need to move some of the data from table1 to table2. For my example, table1 contains 1 field that is a DateTime, we’ll call it table1_Date. table2 also contains 1 field that is a SmallDateTime, we’ll call it table2_Date. I want to do something like this: Insert into table2 table2_Date Select table1_Date From table1 Where ….. I am getting the following error: The conversion from datetime data type to smalldatetime data type resulted in a smalldatetime overflow error. How can I go about converting this on the insert?
hi.. may i know how to convert from mysql to microsoft sql server ?? is it very troublesome ?? coz its quite a big project.. i need to convert frm mysql to sql.. is there any example or reference? thanks
Hello Everyone and thanks for your help in advance. I have an application that inserts a variety of values into a SQL Server database. Among the columns are three DateTime values. I have code working properly on my test server, but when I port the identical code to my production database, I get the following error:
Arithmetic overflow error converting expression to data type datetime. The statement has been terminated
When I remove any type of insert involving date, the application works. I have tried the date in various formats, for instance "09/12/2001" and "20010912", but still get the same error. Obviously, there must be differences in the SQL Servers, but I have never run into this problem before and the current server is running many applications involving dates. I haven't got a clue as to how to solve this problem. Any help is greatly appreciated. Thanks.
I have a control with checkboxes. The checkbox.checked property returns a boolean value. If I want to insert a record into a table that has a corresponding column of type bit, how do I do it?
I triedCType(myChkBox.checked,String), which returns the strings "True" or "False". But, I get the errorThe name 'True' is not permitted in this context. Only constants, expressions, or variables allowed here. Column names are not permitted.I then tried "CAST(" & CType(myChkBox.checked,String) & ",bit)", but got the same error.
I can write a function that will return a 1 or a 0 but that seems ludicrous. Surely there must be a more elegant way to use the result of a checkbox in an SQL statement.
I have a tbale with maybe 30 columns and I'm selecting all where a record number matches a parameter I've passed. That works fine, however is there any way to do some conversions to fields when selecting without having to list out each column? For instance this is what it looks like now:
SELECT * FROM Losses WHERE @AppRecord = AppRecord ORDER BY Record ASC
But I want to convert say one column, is there a way to keep similar syntax instead of listing out each column?
SELECT *, CONVERT(varchar(15), [Losses]) as [Losses] FROM Losses WHERE @AppRecord = AppRecord ORDER BY Record ASC
And the column I'm converting is of type 'money'. I'm converting it to get rid of the extra zeroes at the end. If you know a better way to do it I'd be interested in knowing.