0
にデータを挿入するための位置0で何行がありませんデータベースから値を選択して、DS == nullのようにテキストボックスの値iがデータベースに挿入したいが、私は挿入するとき、私がここに をエラー示すならコードですします私は同様の問題に直面していると私は私が多くのことを試してみました、それらを解決する方法を知らないが、私は解決できないこの問題は、まだ実際には問題は私が欲しいです を助けてくださいデータベース
string query = "Select * From Contacts where [Phone No] = " + textBox00.Text + "";
using (OleDbConnection conn = new OleDbConnection(connStr))
{
using (OleDbDataAdapter adapter = new OleDbDataAdapter(query, conn))
{
conn.Open();
DataSet ds = new DataSet();
if (ds != null)
{
adapter.Fill(ds);
label128.Text = ds.Tables[0].Rows[0]["Name"].ToString();
setaluefortext00001 = ds.Tables[0].Rows[0]["Phone No"].ToString();
setaluefortext00002 = ds.Tables[0].Rows[0]["Address"].ToString();
conn.Close();
}
else
{
adapter.Fill(ds);
connection.Open();
OleDbCommand command1 = new OleDbCommand();
command1.Connection = connection;
command1.CommandText = "insert into Contacts ([Name],[Phone No],[Address])values('" + textBox.Text + "'," + textBox00.Text + ",'" + textBox000.Text + "');";
command1.ExecuteNonQuery();
connection.Close();
label128.Text = textBox.Text;
setaluefortext00002 = textBox00.Text;
setaluefortext00003 = textBox000.Text;
}
テーブルが見つかりません[0] –
大文字の表[0]、 "T"は残念です。申し訳ありませんが試してみましたか? –
yea私は大文字でTを使用していますが、今は正常に動作しています –