こんばんは!
いつもお世話になっております。
visual studio2017にMicrosoft AccessのmdbファイルをWindows Formのtextboxに出力したいです。
OLEDBはokです。でもこのmdbファイルの内容をtextboxに出力をできません。
buttonをクリックするたびに次の情報が出力出来るようにしたいです。
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.Data.OleDb; namespace WindowsFormsApp6 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { OleDbConnection conn = new OleDbConnection(); OleDbCommand comm = new OleDbCommand(); OleDbDataAdapter coss = new OleDbDataAdapter(); conn.ConnectionString = @"Provider = Microsoft.Jet.OLEDB.4.0;Data Source = C:\purpose2019.mdb"; //自分のMDB conn.Open(); comm.CommandText = "SELECT ID, DEPTNO, DNAME, LOC FROM 2019年目標"; //自分のMDB comm.Connection = conn; OleDbDataReader reader = comm.ExecuteReader(); while (reader.Read()) { int id = (int)reader.GetValue(0); string DERTON = (string)reader.GetValue(1); string DNAME = (string)reader.GetValue(2); //自分のMDB string LOC = (string)reader.GetValue(3); } textBox1.Text = (string)reader.GetValue(1); textBox2.Text = (string)reader.GetValue(2); textBox3.Text = (string)reader.GetValue(3); conn.Close(); } private void button2_Click(object sender, EventArgs e) { Close(); } } }
助けが必要です!
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。