syedmeesamali
Member
- Joined
- Jan 16, 2020
- Messages
- 19
- Programming Experience
- 5-10
0
I am trying to populate my database column with name "StockInTable" using Dapper Plus nugget package. My stockin file is as below.
Then my SQL insert operation (using Dapper) looks something like this:
But whenever I execute my code, I get back nothing (i.e. there is no error but my list is not populated and nothing gets inserted to Database). Any help/guidance is much appreciated. BTW I am populating my "stockin" table using an excel sheet input (via EPPlus package) and that is working fine (i.e. I am displaying the stockin table to DGV which shows the list perfectly).
I am trying to populate my database column with name "StockInTable" using Dapper Plus nugget package. My stockin file is as below.
C#:
class Stockin
{
[Key]
public int ID { get; set; }
public DateTime Date { get; set; }
public string Sup_ID { get; set; }
public string Sup_Name { get; set; }
public string Prod_ID { get; set; }
public string Prod_Name { get; set; }
public DateTime Expiry { get; set; }
public float Units { get; set; }
}
Then my SQL insert operation (using Dapper) looks something like this:
C#:
try
{ DapperPlusManager.Entity<Stockin>().Table("StockinTable").Identity(x => x.ID);
List<Stockin> stockin = dataGridView1.DataSource as List<Stockin>;
if (stockin != null)
{
using (IDbConnection db = new SqlConnection(ConnectionString);
{ db.BulkInsert(stockin); }
MessageBox.Show("Purchase Data Imported successfully!");
} MessageBox.Show("Stockin is still null or there is some issue!");
} catch (Exception ex)
{ MessageBox.Show(ex.Message, "Some error occurred! Please check parameters!", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
But whenever I execute my code, I get back nothing (i.e. there is no error but my list is not populated and nothing gets inserted to Database). Any help/guidance is much appreciated. BTW I am populating my "stockin" table using an excel sheet input (via EPPlus package) and that is working fine (i.e. I am displaying the stockin table to DGV which shows the list perfectly).