473,782 Members | 2,393 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(Objec t[] argArray)
{
SqlCommand sqlcmd = new SqlCommand();
SqlConnection sqlconnection1 = new
SqlConnection(c onnectionString );
sqlcmd.Connecti on = sqlconnection1;
Object returnValue;
int paramCount = (int)argArray[1]; // the number of
parameters
sqlcmd.CommandT ext = (string)argArra y[2]; // the whole
query
sqlcmd.CommandT ype =
CommandType.Sto redProcedure;

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

(SqlDbType)argA rray[i + 1],

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

sqlconnection1. Open();

if ((int)argArray[0] == 0)
returnValue = sqlcmd.ExecuteN onQuery(); //
returns the number of rows affected
if ((int)argArray[0] == 1)
returnValue = sqlcmd.ExecuteS calar(); //
returns a single value
else
returnValue =
sqlcmd.ExecuteR eader(CommandBe havior.CloseCon nection); //returns
multiple values

return returnValue;

}

static public bool InsertTuple(str ing Password,DateTi me
PassLastChanged ,string Firstname,strin g 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] = "REGISTRATI ON";
prms[3] = "@PASSWORD" ;
prms[4] = SqlDbType.VarCh ar;
prms[5] = 30;
prms[6] = Password;
prms[7] = "@PASSLASTCHANG ED";
prms[8] = SqlDbType.DateT ime;
prms[9] = 30;
prms[10] = PassLastChanged ;
prms[11] = "@FIRSTNAME ";
prms[12] = SqlDbType.VarCh ar;
prms[13] = 50;
prms[14] = Firstname;
prms[15] = "@LASTNAME" ;
prms[16] = SqlDbType.VarCh ar;
prms[17] = 50;
prms[18] = Lastname;
prms[19] = "@TELNO";
prms[20] = SqlDbType.VarCh ar;
prms[21] = 10;
prms[22] = telno;
prms[23] = "@DOB";
prms[24] = SqlDbType.DateT ime;
prms[25] = 50;
prms[26] = dob;
prms[27] = "@ADDRESS";
prms[28] = SqlDbType.VarCh ar;
prms[29] = 50;
prms[30] = Address;
prms[31] = "@ACCNO";
prms[32] = SqlDbType.VarCh ar;
prms[33] = 4;
prms[34] = Accno;
prms[35] = "@PINCODE";
prms[36] = SqlDbType.VarCh ar;
prms[37] = 4;
prms[38] = Pincode;
prms[39] = "@USERNAME" ;
prms[40] = SqlDbType.VarCh ar;
prms[41] = 30;
prms[42] = Username;
prms[43] = "@SECQUES";
prms[44] = SqlDbType.VarCh ar;
prms[45] = 50;
prms[46] = Secques;
prms[47] = "@SECANS";
prms[48] = SqlDbType.VarCh ar;
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)returnVal ue;
}

return myvar;

}

ALTER PROCEDURE dbo.REGISTRATIO N
(
@PASSWORD VARCHAR(30),
@PASSLASTCHANGE D 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(CUSTOM ER_ID,IS_LOGGED ,PASSWORD,PASS_ LASTCHANGED,LOC KED,CUST_FIRST_ NAME,CUST_LAST_ NAME,
CUST_TELNO,CUST _DOB,CUST_ADDRE SS,CUST_ACC#,CU ST_PINCODE,CUST _USERNAME,CUST_ SECQUES,CUST_SE CANS,
Image1,Image2,I mage3)
VALUES(NEWID(), 0,@PASSWORD,@PA SSLASTCHANGED,
0,@FIRSTNAME,@L ASTNAME,@TELNO, @DOB,@ADDRESS,@ ACCNO,@PINCODE,
@USERNAME,@SECQ UES,@SECANS,@Im age1,@Image2,@I mage3)
RETURN

Apr 5 '07 #1
0 6888

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

Similar topics

1
5038
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 double-checked the path to my error log. It is in /var/www/logs/php_error_log Thanks. :) -Wayne Stevenson
6
4753
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 appreciated. Thanks in advance
9
10904
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 the wheel, right? Everything so far is working well with the Active Directory. The problem I am having is with adding File Permissions to a directory. I am currently using some code courtesy of "Willy Denoyette "
7
1670
by: Leon Shaw | last post by:
Need help understanding? Server Error in '/solo' Application. ---------------------------------------------------------------------------- ---- Object must implement IConvertible. 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.
5
2140
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 ObjectToSerialize) { MemoryStream ms = new MemoryStream(); string theSerializedObject; System.Runtime.Serialization.Formatters.Binary.BinaryFormatter formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
3
2441
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 object :(((( Anyone pls help me to solve this problem!!! thanks in advance,
2
1607
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 CRYPTPROTECT_PROMPTSTRUCT; I defined the variable as IntPtr and then set it to zero CryptProtectData/CryptUnrotectData return without error. The values between the C# and VB for CRYPTPROTECT_PROMPTSTRUCT are exact except for szPrompt C# passes null...
0
9802
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 by the software in your host machine. Stack Trace at System.Net.Sockets.NetworkStream.Write(Byte buffer, Int32 offset, Int32
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10081
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8968
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7494
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6735
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5378
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4044
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3643
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2875
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.