473,385 Members | 1,535 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

bulk copy error: Received invalid row length x from bcp client. Minimum row size is y

Hi,

I am attempting a bulk copy from a c program into SQL Server 2000 using
DBLib in freeTDS 0.63 RC11 (gcc 3.4.3, RH 9). I am getting an error message
that I cannot find any documentation on.

The server is sending back the following: "Received invalid row length 2
from bcp client. Minimum row size is 4."

I know the row is longer 2 bytes (see below). Once this happened I created a
test table and C program. See below. Anyone with any ideas?

Thanks

Program output ---------------->
$ ./test_bcp
bcp'ing This is a test with a length of 14
sent
Msg 4807, Level 16, State 1
Server 'CENTIVIA_10', Line 1
Received invalid row length 2 from bcp client. Minimum row size is 4.
done
<----------------------

Table ddl --------------------->
CREATE TABLE [xxx] (
[col2] [varchar] (32) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY]
GO
<------------------------------------

Compiled using gcc ------------------->
gcc -g -I/home/test_user/dev/freetds-0.63RC11/include -Wall -Wno-strict-aliasing
-g -O2 -c -o test_bcp.o test_bcp.c
gcc -o test_bcp test_bcp.o -L/home/test_user/lib -lsybdb
<----------------------------------
program source (included the msg and error handler
code) -------------------------->
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <sqldb.h>
int
syb_msg_handler(DBPROCESS * dbproc, DBINT msgno, int msgstate, int severity,
char *msgtext, char *srvname, char *procname, int line)
{
char var_value[31];
int i;
char *c;

if (msgno == 5701 || /* database context change */
msgno == 5703 || /* language changed */
msgno == 5704) { /* charset changed */

if (msgtext != NULL && (c = strchr(msgtext, '\'')) != NULL)
{
i = 0;
for (++c; i <= 30 && *c != '\0' && *c != '\''; ++c)
var_value[i++] = *c;
var_value[i] = '\0';

}
return 0;
}

if (severity >= 0 || msgno == 0) {
if (msgno > 0 && severity > 0) {
fprintf(stdout, "Msg %d, Level %d, State %d\n",
(int) msgno, (int) severity, (int) msgstate);
fprintf(stdout, "Server '%s'", srvname);
if (procname != NULL && *procname != '\0')
fprintf(stdout, ", Procedure '%s'",
procname);
if (line > 0)
fprintf(stdout, ", Line %d", line);
fprintf(stdout, "\n");
fprintf(stdout, "%s\n", msgtext);
fflush(stdout);
} else {
fprintf(stdout, "%s\n", msgtext);
fflush(stdout);
}
}

return 0;
}

int
syb_err_handler(DBPROCESS * dbproc, int severity, int dberr, int oserr, char
*dberrstr, char *oserrstr)
{
if (dberr == SYBESMSG)
return INT_CANCEL;
env_set(g_env, "batch_failcount", "1");
fprintf(stdout,
"DB-LIBRARY error (severity %d, dberr %d, oserr %d, dberrstr
%s, oserrstr %s):\n",
severity, dberr, oserr, dberrstr ? dberrstr : "(null)",
oserrstr ? oserrstr : "(null)");
fflush(stdout);
if ((dbproc == NULL) || DBDEAD(dbproc)) {
if (dberr != SYBECOFL) {
exit(255);
}
}

return INT_CANCEL;
}
int main(int argc, char *argv[])
{
DBPROCESS *dbproc;
LOGINREC *login;
DBINT test_int = 99999999;
DBCHAR test_char[32] = "This is a test";

dbinit();
dberrhandle(syb_err_handler);
dbmsghandle(syb_msg_handler);
login = dblogin();
DBSETLPWD(login, "audit");
DBSETLUSER(login, "audit");
dbproc = dbopen(login, "192.168.58.1");
dbuse(dbproc, "audit_dev");

bcp_init(dbproc,"xxx", (BYTE *)NULL, (BYTE *)NULL, DB_IN);
printf("bcp'ing %s with a length of
%d\n",test_char,strlen(test_char));
//ii = bcp_bind(dbproc, (BYTE *) &test_int, 0, -1, NULL, 0, SYBINT4,
1 );
//printf("bound %d\n",ii;
bcp_bind(dbproc, test_char, 0, strlen(test_char), NULL, 0, SYBCHAR,
1 );
bcp_sendrow(dbproc);
printf("sent\n");
bcp_batch(dbproc);
printf("done\n");
return 0;

}
<---------------------------------
Jul 23 '05 #1
1 6353
Patrick Dunnigan (pd*******@adelphia.net) writes:
I am attempting a bulk copy from a c program into SQL Server 2000 using
DBLib in freeTDS 0.63 RC11 (gcc 3.4.3, RH 9). I am getting an error
message that I cannot find any documentation on.

The server is sending back the following: "Received invalid row length 2
from bcp client. Minimum row size is 4."

I know the row is longer 2 bytes (see below). Once this happened I
created a test table and C program. See below. Anyone with any ideas?


I made the necessary changes to your program for it to run with
the DB-Library that comes with SQL Server, and it ran successfully.

So I would strongly suspect that the problem is with the DBLib that
you are using. The error message is obscure, but it probably means
that the client API has messed up.

The only thing I found a but funny in your script is that you don't call
BCP_SETL, which is mandatory for DB-Library for SQL Server. But if that
would be necssary, not even bcp_init would work.

--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Wayno | last post by:
My php logs are coming up empty. I have done all I can think of, and all that made sense to me. Can someone take a look at my php.ini please and tell me what you think may be the problem. I...
3
by: Jim Geissman | last post by:
I am trying to bulk insert a text file. The file has fixed-length fields with no field terminators. BOL says that field terminators are only needed when the data does *not* contain fixed-length...
16
by: Philip Boonzaaier | last post by:
I want to be able to generate SQL statements that will go through a list of data, effectively row by row, enquire on the database if this exists in the selected table- If it exists, then the colums...
4
by: Simon Schaap | last post by:
Hello, I have encountered a strange problem and I hope you can help me to understand it. What I want to do is to pass an array of chars to a function that will split it up (on every location where...
25
by: moondaddy | last post by:
I have an application where users need to upload images and in my web.config file I have a setting like this: <httpRuntime maxRequestLength="512" /> Which restricts image larger than 500k from...
4
by: pradqdo | last post by:
Hi folks, I have a very strange problem when I try to port my client/server program to cygwin. It is a simple shell program where the server executes client's commands + it can send and receive...
1
by: KRISHNA PRAVI | last post by:
the error is "runtime error object expected" here is the code....................................................................................... <script language="javascript"...
0
by: gelangov | last post by:
I am trying to bulk load a flat file into a SQL server table (2005) using the integration services. I got the following error: ] Error: An OLE DB error has occurred. Error code: 0x80004005. An...
6
by: dragiton | last post by:
ASP Code Redirect Error Hello I recently relaunched a website containing asp code which used to work perfectly. However, after resetting up the SQL DB and trying to work out some site bugs I have...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.