Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
M

Member_14194390

@Member_14194390
About
Posts
2
Topics
1
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Export from DataGridView to access _ c#
    M Member_14194390

    Thanks for your help i edit my loop code and it work but i have on other error that was when i copy the result of store procedure from sql and past it into access dont have any problem that worked but when i trying with c# i see error that say

    "

    System.Data.OleDb.OleDbException: 'You must enter a value in the 'Kharid_Detail.KalaKhadamatName' field.'

    "

    when i print my result in c# every thing is true. this is my new code:

    for (int j = 0; j < (TtmsdataGridView.ColumnCount); j++)

                    for (int i = 0; i < (TtmsdataGridView.Rows.Count); i++)
                    {
                        com.CommandText = "INSERT INTO Kharid\_Detail(" + TtmsdataGridView.Columns\[j\].Name.Trim() + ")VALUES(" + TtmsdataGridView.Rows\[i\].Cells\[j\].Value + ")";
    
                        com.ExecuteNonQuery();
                    }
    

    about dataadapter i'm beginer in programing and don't understand how to change my code for use it. thank you

    C# help csharp database com security

  • Export from DataGridView to access _ c#
    M Member_14194390

    Hi I have the following code and I am trying to export information from datagridview to an Access document based but when i have error that was : System.Data.OleDb.OleDbException: 'Number of query values and destination fields are not the same.' please help me to complited this.becouse i cant fix this error. thank you this is my project code:

    private DataTable GetDataTableFromDGV(DataGridView dgv)
    {
    var dt = new DataTable();

            foreach (DataGridViewColumn column in dgv.Columns)
            {
                if (column.Visible)
                {
                    dt.Columns.Add();
                }
    
            }
    
            object\[\] cellValues = new object\[dgv.Columns.Count\];
    
            foreach (DataGridViewRow row in dgv.Rows)
            {
                for (int i = 0; i < row.Cells.Count; i++)
                {
                    cellValues\[i\] = row.Cells\[i\].Value;
                }
                dt.Rows.Add(cellValues);
            }
            return dt;
        }
    

    private void Exportbutton_Click(object sender, EventArgs e)

        {
            openFileDialog1.ShowDialog();
    

    if (KindcomboBox.SelectedIndex == 0)
    {
    OleDbConnection cn = new OleDbConnection(@"Provider=Microsoft.Ace.OLEDB.12.0;Data Source=" + openFileDialog1.FileName + ";Persist Security Info=True");

                cn.Open();
    
                DataTable dt = new DataTable();
    
                dt = GetDataTableFromDGV(TtmsdataGridView);
    
                OleDbCommand com = new OleDbCommand();
    
                com.CommandType = CommandType.Text;
    
                com.Connection = cn;
    
                int dtc = dt.Rows.Count;
    
                MessageBox.Show($"{dtc}");
    
                for (int i = 0; i < (dt.Rows.Count); i++)
                {
                    com.CommandText = "INSERT INTO Kharid\_Detail(" + dt.Columns\[i\].ColumnName.Trim() + ")VALUES(" + (i++) + ",'" +
                        dt.Rows\[i\].ItemArray.GetValue(i) + "')";
    
                    com.ExecuteNonQuery();
                }
    
    C# help csharp database com security
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups