0
정보를 데이터베이스로 이동하기 위해 텍스트 필드에 삽입 할 수 없습니다. 여기 내가 지금까지 가지고있는 것이있다.Visual Studio 텍스트 상자의 데이터를 데이터베이스로 가져 오려면 어떻게합니까?
**public class DBConnectivity
{
private static DbConnection GetConnection()
{
string connString;
// change to your connection string in the following line
connString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=I:\Applications Coursework\quiz.accdb";
return new DbConnection(connString);
}
//method that saves a user in the db
public static void SaveName(string a, string b, string c)
{
DbConnection myConnection = DBConnectivity();
string myQuery = "INSERT INTO user(user_name, user_age, user_country) VALUES ('" + a + "' , " + b + ", " + c + ")";
OleDbCommand myCommand = new DbCommand(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 a = TxbName.Text;
string b = TxbAge.Text ;
string c = TxbCountry.Text;
DBConnectivity.cs (a, b, c);
}
}
에 대한 MSDN에 대한 링크입니다. – Steve
변수 myQuery의 출력을 인쇄 할 수 있습니까 – DevelopmentIsMyPassion
SaveName 함수를 호출하는 것을 볼 수 없습니다. – DevelopmentIsMyPassion