I need to fill one checkbox with some values I saved inside an SQL database.
var numfatura = _transaction.TransDocument + _transaction.TransSerial + _transaction.TransDocNumber;
The variable I need it this one and I saved it inside the SQL like this:
using (SqlConnection conn = new SqlConnection(@"Data source = 2c4138928627\Sage ; Database=ARMINDOData ; User Id=sa ; Password=sage2008+"))
{
SqlCommand command = new SqlCommand("IF OBJECT_ID('UXFaturas', 'U') IS NULL CREATE TABLE UXFaturas(NumFaturas char(250), Cont1 char(250), Cont2 char(250));", conn);
conn.Open();
SqlCommand insertCommand = new SqlCommand("INSERT INTO UXFaturas(NumFaturas, Cont1, Cont2) VALUES (numfatura, cont, cont2)", conn);
command.ExecuteNonQuery();
command.Connection = conn;
command.CommandType = System.Data.CommandType.StoredProcedure;
command.Parameters.AddWithValue("@numfaturas", numfatura);
command.Parameters.AddWithValue("@cont1", cont);
command.Parameters.AddWithValue("@cont2", cont2);
}
}
What I have tried:
I've tried to seach in internet but didnt find anything that was my problem and I have no clue on what should I start. I had this back in the day but I changed my project so this doesnt work anymore but may help:
string path = @"C:\Users\HP8200\Desktop\";
var files = System.IO.Directory.GetFiles(path, "*.txt");
foreach (var item in files)
{
string fileNameOnly = "";
fileNameOnly = Path.GetFileNameWithoutExtension(item);
checkedListBox1.Items.Add(fileNameOnly);
}
I'm using c#.