在尝试将Mssql代码转换为MySQL时,特别是在MysqlCommand请求期间,我创建了CS1026,CS1002和CS1513错误代码, 这是Mssql代码:
try
{
sqlConnect = new System.Data.SqlClient.SqlConnection("server=" + SQLServerAddress + "," + SQLServerPort + "; initial catalog=" + DatabaseName + "; Integrated Security=SSPI");
sqlConnect.Open();
System.Data.SqlClient.SqlCommand sqlCmd = new System.Data.SqlClient.SqlCommand("SELECT ImageFileName, FacePositionXc, FacePositionYc, FacePositionW, FacePositionAngle, Eye1X, Eye1Y, Eye2X, Eye2Y, Template, Image, FaceImage FROM FaceList", sqlConnect);
System.Data.SqlClient.SqlDataReader reader = sqlCmd.ExecuteReader();
while (reader.Read())
我尝试将其转换为MySQL:
string conn = "server=localhost; uid=user;" +
"pwd=password; database=database;";
MySqlConnection connection = new MySqlConnection(conn);
connection.Open();
try
{
MySqlCommand cmd = connection.CreateCommand();
cmd.Connection = connection;
cmd.CommandText = ("SELECT ImageFileName, FacePositionXc, FacePositionYc, FacePositionW, FacePositionAngle, Eye1X, Eye1Y, Eye2X, Eye2Y, Template, Image, FaceImage FROM faces", connection);
MySqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
TFaceRecord fr = new TFaceRecord();
fr.ImageFileName = reader.GetString(4);
fr.FacePosition = new FSDK.TFacePosition();
fr.FacePosition.xc = reader.GetInt32(5);
fr.FacePosition.yc = reader.GetInt32(6);
fr.FacePosition.w = reader.GetInt32(7);
fr.FacePosition.angle = reader.GetFloat(8);
fr.FacialFeatures = new FSDK.TPoint[2];
fr.FacialFeatures[0] = new FSDK.TPoint();
fr.FacialFeatures[0].x = reader.GetInt32(9);
fr.FacialFeatures[0].y = reader.GetInt32(10);
fr.FacialFeatures[1] = new FSDK.TPoint();
fr.FacialFeatures[1].x = reader.GetInt32(11);
fr.FacialFeatures[1].y = reader.GetInt32(12);
fr.Template = new byte[FSDK.TemplateSize];
reader.GetBytes(9, 0, fr.Template, 0, FSDK.TemplateSize);
Image img = Image.FromStream(new System.IO.MemoryStream(reader.GetInt32(14)));
Image img_face = Image.FromStream(new System.IO.MemoryStream(reader.GetInt32(15)));
fr.image = new FSDK.CImage(img);
fr.faceImage = new FSDK.CImage(img_face);
FaceList.Add(fr);
imageList1.Images.Add(fr.faceImage.ToCLRImage());
string fn = fr.ImageFileName;
listView1.Items.Add((imageList1.Images.Count - 1).ToString(), fn.Split('\\')[fn.Split('\\').Length - 1], imageList1.Images.Count - 1);
textBox1.Text += "File '" + fn + "' read from database\r\n";
img.Dispose();
img_face.Dispose();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Exception on loading database");
}
finally
{
if (connection.State == ConnectionState.Open)
{
connection.Close();
// LoadData();
}
}
}
错误是在命令文本末尾生成的。 ",连接)'
删除',连接'创建一个'无法播放'symbol.Byte []类型的对象以输入'System.Convertable''关于错误异常。
任何人都可以建议使用正确的语法或我的错误感谢你。