"INSERT INTO CricketMatch
(FName,LastName,Runs,Matches,Location,DateofMatch,PLayerId)
SELECT
Fname,Lname,Runsby,numberofMatches,MatchLocation,DofMatch,Id
FROM [Text;Data Source=C:\\DB\\;HDR=YES].[filename]";
filename は、拡張子 demo.csv を付けた単なる名前です。パスはありません
cmd.CDataSet da = new DataSet();string filename = Path.GetFileName(txtCSVFilePath.Text);
try {da = this.ConnectCSV(filename);
string connstring = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\\DB\\MatchDetails.accdb";
OleDbConnection conn = new OleDbConnection(connstring);
OleDbCommand cmd = new OleDbCommand();
cmd.CommandType = CommandType.Text;conn.Open();
for (int i = 0; i <= da.Tables["Ss"].Rows.Count - 1; i++){
for (int j = 1; j <= da.Tables["Ss"].Columns.Count - 1;j++){
cmd.CommandText="INSERTINTOCricketMatch(FName,LastName,Runs,Matches,Location,DateofMatch,PLayerId)SELECT(Fname,Lname,Runsby,numberofMatches,MatchLocation,DofMatch,Id) FROM [Text;FMT=Delimited(;);HDR=NO;DATABASE=C:\\DB]." + filename;cmd.Connection = conn; cmd.ExecuteNonQuery();} }}
これは私がしようとしているものです