Register for your free account! | Forgot your password?

You last visited: Today at 20:06

  • Please register to post and access all features, it's quick, easy and FREE!


MYSQL Command Parameter

Reply
 
Old   #1

 
elite*gold: 20
Join Date: Oct 2008
Posts: 328
Received Thanks: 43
C# .NET Byte[] into MYSQL as Binary Large Object (BLOB)

Hey Epvps!

**UPDATE

I've fixed the problem with the parameters yet, but still its not working like in the tutorials I watched (those weren't for mysql but I converted the sql parts to mysql with the correct prefix. I either succeeded to put strings into my database using the parameters. But now there is an error I keep hanging on. (It's not an building error, it comes when I try to inject the byte array.

Unable to cast object of type 'System.Byte[]' to type 'System.IConvertible'.

Any Idea?
Tell me if I need to put the code down here.



jackpotsvr is offline  
Old 01/10/2012, 23:19   #2
 
elite*gold: 21
Join Date: Jul 2005
Posts: 9,193
Received Thanks: 5,311
Excuse me as I'm not very experienced with sql in general... but you have it inside a quote so it's going to be treated as a literal string unless it's a special character (like \). take it out of the quotes and it may work but the more likely outcome is it will use the objects name (similar as if you tried to do Console.WriteLine(JackArray)

That being, said, give it a try and prove me wrong.


Jackcm.CommandText = "Insert into jacktable(Data) values('"+JackArray+"')";


pro4never is offline  
Thanks
1 User
Old 01/11/2012, 12:51   #3

 
elite*gold: 20
Join Date: Oct 2008
Posts: 328
Received Thanks: 43
Quote:
Originally Posted by pro4never View Post
Excuse me as I'm not very experienced with sql in general... but you have it inside a quote so it's going to be treated as a literal string unless it's a special character (like \). take it out of the quotes and it may work but the more likely outcome is it will use the objects name (similar as if you tried to do Console.WriteLine(JackArray)

That being, said, give it a try and prove me wrong.


Jackcm.CommandText = "Insert into jacktable(Data) values('"+JackArray+"')";
I did try that either but doesn't seems to work. I debugged and the byte array is fine. Either the SQL connection is. It do insert data into the database but just doesn't seems to 'listen' to the parameter which should say "Hey, you must be replaced with the byte array (named JackArray)"

Should figure how to make the parameter work, or what else I do wrong !
I hope some one can help me , guess I won't find it myself as I've been looking to this little piece of code for hours now :P

Either still im looking for someone who can comfirm that the parameter token is right :P
jackpotsvr is offline  
Old 01/11/2012, 17:30   #4
 
elite*gold: 0
Join Date: Dec 2010
Posts: 341
Received Thanks: 254
I ran into this problem as well.
The default prefix for variable names it seems is ? not @.
Try ?JackArray, it's what fixed it for me.


.Kinshi is offline  
Thanks
1 User
Old 01/11/2012, 22:08   #5

 
elite*gold: 20
Join Date: Oct 2008
Posts: 328
Received Thanks: 43
Quote:
Originally Posted by .Kinshi View Post
I ran into this problem as well.
The default prefix for variable names it seems is ? not @.
Try ?JackArray, it's what fixed it for me.
When I was seraching on the web I either found someone who was using ? for the parameters. When I change it It still won't work. I guess it's very important to put the parameterer before or after the command itself but I can't find the good combination.

Either I don't know if I should do "?x" aswell in the parameter or just in the command and just parameter "x" if you get what I mean.

Maybe you still have the code you used? (I can understand if you're not willing to leave it here but I guess it can help me much.
Thanks in advance, Jackpotsvr

EDIT --!
Came a step closer, the SQL part works now.
Just come with the error Unable to cast object of type 'system.byte[]' to type 'system.Iconvertible'
jackpotsvr is offline  
Old 01/26/2012, 20:49   #6

 
elite*gold: 20
Join Date: Oct 2008
Posts: 328
Received Thanks: 43
Re-used this old thread for a new problem in the project-


jackpotsvr is offline  
Reply


Similar Threads
Conquer_V2 ini to MySql item Database Command
01/11/2012 - CO2 PServer - Discussions / Questions - 2 Replies
` i do not want to spam the from with stuff so i am posting a ? here. in item the database item data what is Weight, Unknown1, Unknown2, Unknown3, what is the purpose of them?
MySQL Command Line
01/05/2011 - Metin2 PServer - Discussions / Questions - 1 Replies
Wie komm ich dahin ?
[HELP]C# MySQL Command insert if not exsist?
09/04/2009 - CO2 PServer - Discussions / Questions - 8 Replies
MySqlCommand Command = new MySqlCommand("INSERT INTO accounts(AccountID,LogonType) VALUES ('" + fillBox.Text + "','3')", Connection); Now, I want it to check if the value of fillBox.Text doesn't excist before making the account, so It wont create the same account. I tried making it in a try, that didn't help, it just make several accounts with the same name. ~Bas
Where is the mysql command client?
12/02/2008 - EO PServer Hosting - 7 Replies
In the intructions (#23) on the "All Things Guide" it says to put this command in the mysql command client. What exactly do i put in, and where! Please help! -Nicolexo



All times are GMT +1. The time now is 20:06.


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Abuse
Copyright ©2018 elitepvpers All Rights Reserved.