Note that there are some explanatory texts on larger screens.

plurals
  1. PO(OleDb) ExecuteNonQuery error - Type name is invalid
    text
    copied!<p>I pretty new in writing asp.net codes and I can't solve a problem. Every time I try to register I get the following error:</p> <pre><code>Type name is invalid. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.OleDb.OleDbException: Type name is invalid. Source Error: Line 60: } Line 61: Line 62: cmnd.ExecuteNonQuery(); Line 63: this.cnct.Close(); Line 64: } </code></pre> <p>The source code is:</p> <pre><code> public class Connection { private OleDbConnection cnct; public Connection(string dbPath) { this.cnct = new OleDbConnection(@"Provider=Microsoft.Jet.OleDb.4.0; Data Source=" + dbPath); } /// &lt;param name="types"&gt;'c' - VarChar, 'C' - Char, 'n' - VarNumeric, 'b' - Boolean&lt;/param&gt; public void Insert(string tableName, string[] inputs, char[] types) { string sql = "INSERT INTO " + tableName + " VALUES ("; for (int i = 0; i &lt; inputs.Length - 1; i++) sql += "@p" + i + ","; sql += "@p" + (inputs.Length - 1) + ")"; this.cnct.Open(); OleDbCommand cmnd = new OleDbCommand(sql, this.cnct); for (int i = 0; i &lt; inputs.Length; i++) { if (types[i] == 'c') { cmnd.Parameters.Add("@p" + i, OleDbType.VarChar); cmnd.Parameters["@p" + i].Value = inputs[i]; } else if (types[i] == 'C') { cmnd.Parameters.Add("@p" + i, OleDbType.Char); cmnd.Parameters["@p" + i].Value = inputs[i]; } else if (types[i] == 'n') { cmnd.Parameters.Add("@p" + i, OleDbType.VarNumeric); cmnd.Parameters["@p" + i].Value = double.Parse(inputs[i]); } else if (types[i] == 'b') { cmnd.Parameters.Add("@p" + i, OleDbType.Boolean); cmnd.Parameters["@p" + i].Value = bool.Parse(inputs[i]); } } cmnd.ExecuteNonQuery(); this.cnct.Close(); } } </code></pre> <p>and the Insert method is called using</p> <pre><code>Connection cnct = new Connection(Server.MapPath("App_Data/WMUdb.mdb")); cnct.Insert("members", values, new char[7] { 'c', 'c', 'c', 'c', 'C', 'n', 'b' }); </code></pre> <p>(where</p> <pre><code>values = new string[7] {"userName","my name","pswrd123","email@example.com","2000-01-01"}; </code></pre> <p>).</p> <p>What should I do to solve it?</p> <p>Thanks a lot.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload