Program works on Visual Studio but not work as ".exe"
Hello,
Im just working on a program that changes some row's values in an excel file. Program has just about 60 rows. When i debug my program at Visual Studio (pressing F5), its working properly and made some changes at excel file. Its ok. But when I only click my project's "excel.exe" file, it doesnt work properly. Its getting no error but it didnt any changes at this excel file. And i didnt move this "excel.exe" file to anywhere, i started it in projects folder.(/bin/debug)
Its really weird and i didnt know what is the problem?
My all codes below;
-------------------------
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
namespace badi
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}I
private void button1_Click(object sender, EventArgs e)
{
OleDbConnection baglanti = new
OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data
Source=dosya.xlsx;Extended Properties=Excel 12.0 Xml;");
baglanti.Open();
string query = "SELECT [Ci Adi],[Baslangic Tarihi],[Bitis Tarihi],[Sira],[Kategori] FROM [Sheet6$A:L]";
OleDbDataReader rdr;
OleDbCommand komut = new OleDbCommand(query, baglanti);
rdr = komut.ExecuteReader();
while (rdr.Read())
{
DateTime tarih1_baslangic = DateTime.Parse(rdr["Baslangic Tarihi"].ToString());
DateTime tarih1_bitis = DateTime.Parse(rdr["Bitis Tarihi"].ToString());
string ci_adi = rdr["Ci Adi"].ToString();
string query_ci = "SELECT [Ci Adi],[Baslangic Tarihi],[Bitis
Tarihi],[Sira],[Kategori] FROM[Sheet6$A:L] WHERE [Ci Adi]='" + ci_adi +
"'";
OleDbDataReader rdr_ci;
OleDbCommand komut_ci = new OleDbCommand(query_ci, baglanti);
rdr_ci = komut_ci.ExecuteReader();
while (rdr_ci.Read())
{
string birincidongu = rdr_ci["Sira"].ToString();
string ikincidongu = rdr["Sira"].ToString();
DateTime tarih2_baslangic = DateTime.Parse(rdr_ci["Baslangic Tarihi"].ToString());
DateTime tarih2_bitis = DateTime.Parse(rdr_ci["Bitis Tarihi"].ToString());
if (int.Parse(rdr_ci["Sira"].ToString()) != int.Parse(rdr["Sira"].ToString()))
{
if (int.Parse(rdr_ci["Sira"].ToString()) > int.Parse(rdr["Sira"].ToString()))
{
if (tarih1_baslangic > tarih2_baslangic && tarih2_bitis > tarih1_baslangic)
{
OleDbCommand komut_ustune_yaz = new OleDbCommand("UPDATE [Sheet6$] SET
[Kategori]='OK' WHERE [Sira]='" + rdr["Sira"] + "' ", baglanti);
komut_ustune_yaz.ExecuteNonQuery();
}
else if (tarih2_baslangic >= tarih1_baslangic && tarih2_baslangic <= tarih1_bitis)
{
if (rdr["Kategori"].ToString() == "OK")
{
}
else
{
OleDbCommand komut_ustune_yaz = new OleDbCommand("UPDATE [Sheet6$] SET
[Kategori]='OK' WHERE [Sira]='" + rdr_ci["Sira"] + "' ", baglanti);
komut_ustune_yaz.ExecuteNonQuery();
}
}
}
}
}
rdr_ci.Close();
}
}
-----------