我有一个带有Insert Into命令的API,如下所示:
index.php
elseif ($tag == "addpatient" && $isAdmin) {
// Request type is insert a patient
$pid = getParamValue('pid');
$svnr = getParamValue('svnr');
$fname = getParamValue('fname');
$lname = getParamValue('lname');
$gender = getParamValue('gender');
$age = getParamValue('age');
$created_at = getParamValue('created_at');
// Add patient
$patient = $db->addPatient($pid, $svnr, $fname, $lname, $gender, $age, $created_at);
if ($patient != false) {
// patient stored successfully
} else {
// patient failed to store
$response["error"] = "JSON Error occured in saving new patient.";
}
DB_Functions.php
/**
* Adding a new patient to mysql database
*/
public function addPatient($pid, $svnr, $fname, $lname, $gender, $age, $created_at) {
$svnr = addslashes($svnr);
$fname = addslashes($fname);
$lname = addslashes($lname);
$result = mysql_query("INSERT INTO p_patient (p_id, p_svnr, p_firstname, p_lastname, p_gender, p_age, p_createdAt) VALUES ('$pid', '$svnr', '$fname', '$lname', '$gender', '$age', '$created_at')") or die(mysql_error());
// check for successful store
return $result;
}
我想要的是将它与C#Application连接以插入数据库中的值。例如,我有一个带文本框的WPF应用程序,当我点击一个按钮时,它应该将文本框中的值插入数据库。有没有一个示例代码如何实现?