Bueno soy nuevo en esto y estoy haciendo un programa conjunto con bases de datos...
pero tengo un problema en el INSERT INTO:
Código:
y la tabla esta asi:private void button21_Click(object sender, EventArgs e) { IniFile I = new IniFile(@"Config.ini"); serverip = I.ReadString("MySql", "Ip"); mysqlDatabase = I.ReadString("MySql", "Database"); mysqlUser = I.ReadString("MySql", "User"); mysqlPassword = I.ReadString("MySql", "Password"); string MyConString = "SERVER=" + serverip + ";" + "DATABASE=" + mysqlDatabase + ";" + "UID=" + mysqlUser + ";" + "PASSWORD=" + mysqlPassword + ";"; connection = new MySqlConnection(MyConString); connection.Open(); SqlCommand cmd = new SqlCommand("INSERT INTO npcs (id, name, type, lookface, mapid, cellx, celly) VALUES (" + "'" + textBox2.Text + "', '" + textBox16.Text + "', '" + textBox6.Text + "', '" + textBox4.Text + "', '" + textBox5.Text + "', '" + x.Text + "', '" + y.Text + "')"); cmd.ExecuteNonQuery(); }
-- ----------------------------
-- Table structure for `npcs`
-- ----------------------------
DROP TABLE IF EXISTS `npcs`;
CREATE TABLE `testtaaaa` (
`id` int(4) unsigned zerofill NOT NULL default '0000',
`ownerid` int(4) unsigned default '0',
`playerid` int(4) unsigned default '0',
`name` varchar(30) character set utf8 collate utf8_bin NOT NULL default '',
`type` int(4) unsigned zerofill default '0000',
`lookface` int(4) unsigned zerofill default '0000',
`idxserver` int(4) default '-1',
`mapid` int(4) unsigned zerofill default '0000',
`cellx` int(4) unsigned zerofill default '0000',
`celly` int(4) unsigned zerofill default '0000',
`task0` int(4) unsigned zerofill default '0000',
`task1` int(4) unsigned zerofill default '0000',
`task2` int(4) unsigned zerofill default '0000',
`task3` int(4) unsigned zerofill default '0000',
`task4` int(4) unsigned zerofill default '0000',
`task5` int(4) unsigned zerofill default '0000',
`task6` int(4) unsigned zerofill default '0000',
`task7` int(4) unsigned zerofill default '0000',
`data0` int(4) NOT NULL default '0',
`data1` int(4) NOT NULL default '0',
`data2` int(4) NOT NULL default '0',
`data3` int(4) NOT NULL default '0',
`datastr` varchar(15) character set utf8 collate utf8_bin default 'ط·آ·ط¢آ·ط·آ¢ط¢آ',
`linkid` int(4) unsigned zerofill NOT NULL default '0000',
`life` smallint(2) unsigned zerofill NOT NULL default '00',
`maxlife` smallint(2) unsigned zerofill NOT NULL default '00',
`base` int(4) unsigned zerofill NOT NULL default '0000',
`sort` smallint(2) unsigned zerofill NOT NULL default '00',
`itemid` int(4) unsigned zerofill default NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of npcs
-- ----------------------------
INSERT INTO `npcs` VALUES ('5517', '0', '0', '...', '0002', '5836', '-1', '1006', '0019', '0029', '0000', '0000', '0000', '0000', '0000', '0000', '0000', '0000', '0', '0', '0', '0', 'ط·آ·ط¢آ·ط·آ¢ط¢آ', '0000', '00', '00', '0000', '00', null);
Me dise que "ExecuteNonQuery: la propiedad Connection no se ha inicializado."
Y quisiera saver como hacer un querry... gracias...
Espero me puedan ayudar gracias!