473,320 Members | 1,881 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,320 software developers and data experts.

Error: Failed to convert parameter value from a String to a Byte[]. (Need Help Urgently)

Here is the code for executing stored procedure ExecuteSP() [no
prob. with that] , and object that sets all its parameters in other
functions and the stored procedure. I think it has something to do
with db datatypes since this is the first time, i am working with
databases and not really much of an expert.

How can I rectify it? One thing more...... Should I be passing a
value to type bit in sql server as 0 or '0'..... '0' is for character
i guess

private static Object ExecuteSP(Object[] argArray)
{
SqlCommand sqlcmd = new SqlCommand();
SqlConnection sqlconnection1 = new
SqlConnection(connectionString);
sqlcmd.Connection = sqlconnection1;
Object returnValue;
int paramCount = (int)argArray[1]; // the number of
parameters
sqlcmd.CommandText = (string)argArray[2]; // the whole
query
sqlcmd.CommandType =
CommandType.StoredProcedure;

for (int j = 0, i = 3; j < paramCount; i += 4, j++)
{
SqlParameter myPrm = new
SqlParameter((string)argArray[i],

(SqlDbType)argArray[i + 1],

(int)argArray[i + 2]);
myPrm.Value = argArray[i + 3];
sqlcmd.Parameters.Add(myPrm);
}

sqlconnection1.Open();

if ((int)argArray[0] == 0)
returnValue = sqlcmd.ExecuteNonQuery(); //
returns the number of rows affected
if ((int)argArray[0] == 1)
returnValue = sqlcmd.ExecuteScalar(); //
returns a single value
else
returnValue =
sqlcmd.ExecuteReader(CommandBehavior.CloseConnecti on); //returns
multiple values

return returnValue;

}

static public bool InsertTuple(string Password,DateTime
PassLastChanged,string Firstname,string Lastname,string telno,
DateTime dob,string Address,string
Accno,string Pincode,string Username,
string Secques,string Secans,string
img1,string img2,string img3)
{
object[] prms = new object[63];

prms[0] = 1;
prms[1] = 15;
prms[2] = "REGISTRATION";
prms[3] = "@PASSWORD";
prms[4] = SqlDbType.VarChar;
prms[5] = 30;
prms[6] = Password;
prms[7] = "@PASSLASTCHANGED";
prms[8] = SqlDbType.DateTime;
prms[9] = 30;
prms[10] = PassLastChanged;
prms[11] = "@FIRSTNAME";
prms[12] = SqlDbType.VarChar;
prms[13] = 50;
prms[14] = Firstname;
prms[15] = "@LASTNAME";
prms[16] = SqlDbType.VarChar;
prms[17] = 50;
prms[18] = Lastname;
prms[19] = "@TELNO";
prms[20] = SqlDbType.VarChar;
prms[21] = 10;
prms[22] = telno;
prms[23] = "@DOB";
prms[24] = SqlDbType.DateTime;
prms[25] = 50;
prms[26] = dob;
prms[27] = "@ADDRESS";
prms[28] = SqlDbType.VarChar;
prms[29] = 50;
prms[30] = Address;
prms[31] = "@ACCNO";
prms[32] = SqlDbType.VarChar;
prms[33] = 4;
prms[34] = Accno;
prms[35] = "@PINCODE";
prms[36] = SqlDbType.VarChar;
prms[37] = 4;
prms[38] = Pincode;
prms[39] = "@USERNAME";
prms[40] = SqlDbType.VarChar;
prms[41] = 30;
prms[42] = Username;
prms[43] = "@SECQUES";
prms[44] = SqlDbType.VarChar;
prms[45] = 50;
prms[46] = Secques;
prms[47] = "@SECANS";
prms[48] = SqlDbType.VarChar;
prms[49] = 50;
prms[50] = Secans;
prms[51] = "@Image1";
prms[52] = SqlDbType.Image;
prms[53] = 100;
prms[54] = img1;
prms[55] = "@Image2";
prms[56] = SqlDbType.Image;
prms[57] = 100;
prms[58] = img2;
prms[59] = "@Image3";
prms[60] = SqlDbType.Image;
prms[61] = 50;
prms[62] = img3;
bool myvar = false;
Object returnValue = ExecuteSP(prms);
if (returnValue == null)
{
myvar = false;
}
else
{
myvar = (bool)returnValue;
}

return myvar;

}

ALTER PROCEDURE dbo.REGISTRATION
(
@PASSWORD VARCHAR(30),
@PASSLASTCHANGED DATETIME,
@FIRSTNAME VARCHAR(50),
@LASTNAME VARCHAR(50),
@TELNO VARCHAR(10),
@DOB DATETIME,
@ADDRESS VARCHAR(100),
@ACCNO VARCHAR(10),
@PINCODE VARCHAR(4),
@USERNAME VARCHAR(30),
@SECQUES VARCHAR(50),
@SECANS VARCHAR(50),
@Image1 Image,
@Image2 Image,
@Image3 Image
)
AS
INSERT INTO
CUSTOMER(CUSTOMER_ID,IS_LOGGED,PASSWORD,PASS_LASTC HANGED,LOCKED,CUST_FIRST_NAME,CUST_LAST_NAME,
CUST_TELNO,CUST_DOB,CUST_ADDRESS,CUST_ACC#,CUST_PI NCODE,CUST_USERNAME,CUST_SECQUES,CUST_SECANS,
Image1,Image2,Image3)
VALUES(NEWID(),0,@PASSWORD,@PASSLASTCHANGED,
0,@FIRSTNAME,@LASTNAME,@TELNO,@DOB,@ADDRESS,@ACCNO ,@PINCODE,
@USERNAME,@SECQUES,@SECANS,@Image1,@Image2,@Image3 )
RETURN

Apr 5 '07 #1
0 6824

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...
6
by: Peter Frost | last post by:
Please help I don't know if this is possible but what I would really like to do is to use On Error Goto to capture the code that is being executed when an error occurs. Any help would be much...
9
by: Ben Dewey | last post by:
Project: ---------------------------- I am creating a HTTPS File Transfer App using ASP.NET and C#. I am utilizing ActiveDirectory and windows security to manage the permissions. Why reinvent...
7
by: Leon Shaw | last post by:
Need help understanding? Server Error in '/solo' Application. ---------------------------------------------------------------------------- ---- Object must implement IConvertible....
5
by: Solel Software | last post by:
Hello, I am attempting to serialize an object for storage in a DB field and them deserialize it later on. I have managed to Serialize it using private string SerializeObject(object...
3
by: Adriano | last post by:
Hello, when I try to print something, either DataGrid or from Crystal Report viever the folowing error message appears and cancels printing: Object reference not set to an instance of an...
2
by: DazedAndConfused | last post by:
I converted a C# example of using dll crypt32 to VB .NET. The converted example fails when Encypting/Decypting. I found that if instead of defining a variable as and setting the values for...
0
by: Buddy Home | last post by:
Hello, I'm trying to upload a file programatically and occasionally I get the following error message. Unable to write data to the transport connection: An established connection was aborted...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.