How JustAnswer Works:
  • Ask an Expert
    Experts are full of valuable knowledge and are ready to help with any question. Credentials confirmed by a Fortune 500 verification firm.
  • Get a Professional Answer
    Via email, text message, or notification as you wait on our site. Ask follow up questions if you need to.
  • 100% Satisfaction Guarantee
    Rate the answer you receive.
Ask chrisaw Your Own Question
chrisaw
chrisaw, DevOps Manager
Category: Programming
Satisfied Customers: 13
Experience:  DevOps Manager with over 10 years experience in the DevOps and IT field.
58355812
Type Your Programming Question Here...
chrisaw is online now

There,I've spent the last 3-4 years creating a game

Resolved Question:

Hi there,I've spent the last 3-4 years creating a game emulator and all of the functions work with the exception of one feature. On a specific action the character is to create a new editable room, however when the code (which is below) is executed the Emulator states the index was outside the bounds of array. The code is in c#using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient())
{
MySqlClient.ExecuteNonQuery("INSERT INTO rooms(id,type,owner_id,name,description,pub_internal_name,tags,access_type,password,category,current_users,max_users,swfs,score,icon,model,allow_pets,allow_pet_eating,disable_blocking,hide_walls,thickness_wall,thickness_floor,decorations,allow_fight) VALUES('','flat','1','Awaiting Construction...','Room to be designed and connected.','','','open','','0','0','100','','0','1|0|1|4,1','model_a','1','0','1','0','0','0','landscape=0.0|wallpaper=0|floor=0','1')");
Session.SendData(RoomChatComposer.Compose(Actor.Id, "*Room Successfully Created",0, ChatType.Shout));
}The Index (named ID) is set at auto-increment so no value has to be inserted. Is there alterations you could suggest?Thanks in advance,Rhyse Crook
Submitted: 1 year ago.
Category: Programming
Expert:  chrisaw replied 1 year ago.
Hi Rhyse, I'm no expert on C# ***** but I can tell you that it's very likely the error you are seeing there is from MySQL rather than your C# ***** specifically. Are you able to provide some details about the environment this is running on? What version of MySQL are you running on and could you provide the column types in the "rooms" table? This should help either me or another expert assist you better in resolving this issue. :) Thanks! Christopher
Customer: replied 1 year ago.
its running MySQL 5.7 and the table column information is attached.thanks again,Rhyse
Expert:  adamd-mod replied 1 year ago.
Hello there,
I've been working hard to find a Professional to assist you with your question, but sometimes finding the right Professional can take a little longer than expected.
I wonder whether you're ok with continuing to wait for an answer. If you are, please let me know and I will continue my search. If not, feel free to let me know and I will cancel this question for you.
Please note, I am just a moderator for this category, I can only try and find experts to help, I can't answer the question itself.
Thank you!
Adam
Customer: replied 1 year ago.
Please continue to search, hopefully as quick as possible :)Rhyse
Expert:  adamd-mod replied 1 year ago.
Hello,
Thanks for getting back to me.
We will continue to look for a Professional to assist you.
Thank you for your patience,
Adam
Expert:  chrisaw replied 1 year ago.
Hi Rhyse, Apologies for the delay on getting back to you about this - could you possibly clarify which line of the C# ***** you pasted above results in this error? I just want to confirm that the error is actually coming from the SQL query and not the Session.SendData line essentially. It does seem strange that you would get this kind of error from an INSERT query. Have you tried the query without the list of fields ( i.e. changing the query to the following: INSERT INTO rooms VALUES('','flat','1','Awaiting Construction...','Room to be designed and connected.','','','open','','0','0','100','','0','1|0|1|4,1','model_a','1','0','1','0','0','0','landscape=0.0|wallpaper=0|floor=0','1'); ) If so - do you receive the same error? Thanks! Christopher
Customer: replied 1 year ago.
Hi there,Thanks for all the help but I decided to code a second program to be used by content administrators to be able to execute the sql, while I'm having teething problems with this, it is something I will overcome.Thanks again,Rhyse
Customer: replied 1 year ago.
However, you may be able to help. Please bare in mind this is VB.Net and SQL. The error is with the SQL:INSERT INTO rooms ('id', 'type', 'owner_id', 'name', 'description', 'pub_internal_name', 'tags', 'access_type', 'password', 'category', 'current_users', 'max_users', 'swfs', 'score', 'icon', 'model', 'allow_pets', 'allow_pet_eating', 'disable_blocking', 'hide_walls', 'thickness_floor', 'decorations', 'allow_fight') VALUES ('', 'flat', '1', '" & TextBox1.Text & "', 'under construction', '', '', 'open', '', '', '0', '100', '', '', '1|0|1|4,1', '" & ComboBox1.Text & "', '0', '0', '1', '0', '0', 'landscape=0.0|wallpaper=0|floor=0', '1', '')The error is:
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ''id', 'type', 'owner_id', 'name', 'description', 'pub_internal_name', 'tags', 'a' at line 1I've checked all the columns are correct, the data to be inserted is correct and there is the right amount of parenthesis used. any suggestions?Rhyse
Expert:  chrisaw replied 1 year ago.
Hi Rhyse, It took a fair bit of staring at this to figure out what the problem was but it looks like the counts don't match up in the values with the columns. I've converted this to CSV and taken a screenshot so you can see what I'm talking about which I have attached (see X and Y). That having been said - you don't actually have to include the column names in your SQL queries at all for MySQL - your query could be shortened to just: INSERT INTO rooms VALUES ('', 'flat', '1', '" & TextBox1.Text & "', 'under construction', '', '', 'open', '', '', '0', '100', '', '', '1|0|1|4,1', '" & ComboBox1.Text & "', '0', '0', '1', '0', '0', 'landscape=0.0|wallpaper=0|floor=0', '1', '') That would avoid this problem in future and probably save you a fair bit of debugging. If this answer does resolve your problem I would greatly appreciate if you could leave a rating when you have a few moments spare. :) Thanks! Christopher
chrisaw, DevOps Manager
Category: Programming
Satisfied Customers: 13
Experience: DevOps Manager with over 10 years experience in the DevOps and IT field.
chrisaw and other Programming Specialists are ready to help you