0
의 C#을 사용하여 홈에 데이터를 삽입 할 수는 없지만 데이터를 삽입 할 수 없지만 오류는내가 여러 번 시도
public static void SaveCorresDetails(string cN, string cId, string pId, string rI)
{
OleDbConnection myConnection = GetConnection();
string myQuery = "INSERT INTO RAHANICorrespondent(DateIssue, Action, Recipient, Remarks) VALUES ('" + cN + "' , '" + cId + "', '" + pId + "','" + rI + "')";
OleDbCommand myCommand = new OleDbCommand(myQuery, myConnection);
try
{
myConnection.Open();
myCommand.ExecuteNonQuery();
}
catch (Exception ex)
{
Console.WriteLine("Exception in DBHandler", ex);
}
finally
{
myConnection.Close();
}
}
도와주세요이 데이터를 추가 할 수있는 클래스 파일 될 것
protected void Button1_Click(object sender, EventArgs e)
{
string n = TextBox1.Text.Trim();
string c = TextBox2.Text.Trim();
string p = TextBox3.Text.Trim();
string r = TextBox4.Text.Trim();
// save the data into the database
Data.SaveCorresDetails(n, c, p, r);
Label6.Text = "Package amount of " + n + " was saved";
TextBox1.Text = "";
TextBox2.Text = "";
TextBox3.Text = "";
TextBox4.Text = "";
}
감사합니다 ...
ExecuteNonQuery는 무엇을 반환합니까? –
execute non query를 사용하여 연결에 대한 Transact-SQL 문을 실행하고 영향을받은 행 수를 반환합니다. –
아니면 -1이 반환됩니까? 또한 콘솔 앱입니까? –