Problems in saving contents of datagridview to database
<p>I'm developing a simple database related application. The GUI consists of datagrid view and a "save" button. The datagridview uses a  dataset as its source. The dataset is in turn populated by fetching data from a SQL Server Compact Edition database file.</p>

<p>The problem is when i make changes to content of database using the datagridview and then proceed to change it.</p>

<pre><code>SqlCeDataAdapter da = new SqlCeDataAdapter();
da.UpdateCommand = Con.CreateCommand(); // Con is SqlCeCommand object
da.UpdateCommand.CommandText = "update TempTable set " +
"S.No = @S.No , Name = @Name";

this.AddParams(da.UpdateCommand, "S.No", "Name");
da.Update(ds); // ds is the dataset used as source by the datagridview
</code></pre>

<p>and AddParams Method ...</p>

<pre><code>private void AddParams(SqlCeCommand cmd, params string[] cols)
        {
            foreach (string col in cols)
            {
                cmd.Parameters.Add("@" + col, SqlDbType.Char, 0, col);
            }
        }
</code></pre>

<p>Problem is i'm getting an ArguementException with description as "char" in the following line </p>

<pre><code>cmd.Parameters.Add("@" + col, SqlDbType.Char, 0, col);
</code></pre>

<p>i believe is due to the fact that one of the parameter is a varchar while the other is an integer. So how i get this done ?</p>

<p>p.s. i'm a beginner in Dot Net &amp; Programming.</p>
