我想在ODBC DSN MySql连接中执行多个查询。如果我只执行一个查询它工作正常。但是,如果我尝试执行多次,我总会得到错误:
"ERROR [42000] [MySQL][ODBC 5.1 Driver][mysqld-5.0.84-community]You have an error in your SQL syntax; check the
manual that corresponds to your MySQL server version for the right syntax to use near 'UPDATE TABLE SET ID = '5' WHERE TYPE = '500' AND ID'
at line 2"
我的剧本:
$qrys = @"
UPDATE TABLE SET ID = '5' WHERE TYPE = '500' AND ID = '0';
UPDATE TABLE SET ID = '6' WHERE TYPE = '600' AND ID = '0';
UPDATE TABLE SET ID = '7' WHERE TYPE = '700' AND ID = '0';
UPDATE TABLE SET ID = '8' WHERE TYPE = '800' AND ID = '0';
"@
$conn = new-object System.Data.Odbc.OdbcConnection
$conn.connectionstring = "DSN=MYDB"
$conn.open()
foreach ($sqlCommand in $qrys) {
$cmd = New-object System.Data.Odbc.OdbcCommand($sqlCommand,$conn)
$dataset = New-Object System.Data.DataSet
(New-Object System.Data.Odbc.OdbcDataAdapter($cmd)).Fill($dataSet)
}
$conn.Close()
有什么想法吗?提前致谢
答案 0 :(得分:2)
默认情况下,MySql不启用多个查询。将public class ShootableBox : MonoBehaviour {
Animator anim;
public int currentHealth = 3;
public int enemyKilled; // Count how many enemies you have killed
public float currentHealthLength;
bool isSinking; // To trigger the dead enemy to sink
public float sinkSpeed = 1f; // Sink speed
void Start() {
anim = GetComponent<Animator>();
currentHealthLength = Screen.width/2;
enemyKilled = 0;
}
void Update ()
{
// If the enemy should be sinking...
if(isSinking)
{
transform.Translate (-Vector3.up * sinkSpeed * Time.deltaTime);
}
}
public void Damage(int damageAmount)
{
//subtract damage amount when Damage function is called
currentHealth -= damageAmount;
//Check if health has fallen below zero
if (currentHealth <= 0) {
enemyKilled = enemyKilled + 1;
//if health has fallen below zero, deactivate it
anim.SetTrigger ("isDead");
//transform.GetComponent<NavMeshAgent> ().Stop ();
// Find and disable the Nav Mesh Agent.
GetComponent <NavMeshAgent> ().enabled = false;
// Find the rigidbody component and make it kinematic (since we use Translate to sink the enemy).
GetComponent <Rigidbody> ().isKinematic = true;
Invoke ("StartSinking", 2.5f);
} else {
anim.SetTrigger("isHit");
anim.SetTrigger("isRun2");
}
}
public void StartSinking() {
// The enemy should now sink.
isSinking = true;
// After 2 seconds destory the enemy.
Destroy (gameObject, 8f);
}
// My problem is somewhere on this part
public void OnGUI() {
GUI.contentColor = Color.yellow;
if (enemyKilled != 0) {
GUI.Box(new Rect(5, 5, currentHealthLength, 20), "Enemies killed: " + enemyKilled );
}
}
}
添加到连接字符串,或在DSN配置对话框中启用复选框OPTIONS=67108864
:
请参阅:https://dev.mysql.com/doc/connector-odbc/en/connector-odbc-configuration-connection-parameters.html