locked
ERROR [HY104] [Microsoft][ODBC Microsoft Access Driver]Invalid precision value RRS feed

  • Question

  • User1052662409 posted

    hi all,

            I am using MSaccess using System.Data.Oledb name space. I am using DSN for using the dataabase

    see my code

    protected void Update_Data()  //for updating the data
        {
            con.Open();
            string strSql = "update tblEnergy set EquipName=?,Potential=?,Advantages=?,Specifications=?,Financial=?,sup1=?,sup2=?,sup3=?,Benifit=? where sno=?";
            OdbcCommand com = new OdbcCommand(strSql,con);
            com.Parameters.AddWithValue("EquipName",txtEquipName.Text);
            com.Parameters.AddWithValue("Potential", txtPoten.Text);
            com.Parameters.AddWithValue("Advantages", txtAdvantages.Text);
            com.Parameters.AddWithValue("Specifications", txtSpecific.Text);
            com.Parameters.AddWithValue("Financial", txtFinance.Text);
            com.Parameters.AddWithValue("sup1", txtSup1.Text);
            com.Parameters.AddWithValue("sup2", txtSup2.Text);
            com.Parameters.AddWithValue("sup3", txtSup3.Text);
            com.Parameters.AddWithValue("Benifit", txtBenifit.Text);
            com.Parameters.AddWithValue("sno", lblSno.Text);
            int row = com.ExecuteNonQuery();
            if (row != 0)
            {
     
            }


        }

    shows error on bolded line

    ERROR [HY104] [Microsoft][ODBC Microsoft Access Driver]Invalid precision value

    let me know

    thanks

    Monday, June 28, 2010 4:43 AM

Answers

  • User-1199946673 posted

    When using OLEDB I never experienced a problem like this. Since I never use ODBC, I can't say why this is happening. Start replacing Add with AddWithValue one by one, trying to pinpoint which field(s) is (are) causing this problem.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, July 1, 2010 4:29 PM

All replies

  • User-1199946673 posted

    I am using MSaccess using System.Data.Oledb name space
     

    No you don't!

    OdbcCommand com = new OdbcCommand(strSql,con);

    But you should us OleDb. Examples can be found here:

    http://www.mikesdotnetting.com/Article/26/Parameter-Queries-in-ASP.NET-with-MS-Access

    Please let us now if this error also occurs when using OleDb?

    Monday, June 28, 2010 2:46 PM
  • User1052662409 posted

    sorry hans_v I am using Odbc not Oledb that by mistake I wrote. but why this error is comming, I know how to use parameters with Odbc or Oledb or Sql. but i am not getting this error's source.

    thanks

    Monday, June 28, 2010 11:11 PM
  • User-1199946673 posted

    I never had this error either, but that's because I never use ODBC but I use OleDb instead, which is recommended. When searching on google, it probably has something to do with a MEMO field. I would advice you to start using OleDB, maybe than the error will be gone?

    Tuesday, June 29, 2010 3:36 AM
  • User1052662409 posted

    so now I want to use Oledb namespace instead of ODBC.

    i am using databse through DSN

    my current wenconfu\ig while i am using ODBC

    <configuration >
      <appSettings>
        <add key="contest" value="DSN=jicadsn;Uid=gaurav;Pwd=******"></add>

      </appSettings>

    and making connection object con like below

    OdbcConnection con = new OdbcConnection(ConfigurationSettings.AppSettings["contest"]);

    But if I use Oledb the how to define this connection

    cos it shows error

    An OLE DB Provider was not specified in the ConnectionString.  An example would be, 'Provider=SQLOLEDB;'.

    while define like

    OleDbConnection con = new OleDbConnection(ConfigurationSettings.AppSettings["contest"]);

    so i didnt specified DB provider while using ODBC but shifted to Oledb shows error

    how to get through it

    thanks


    Wednesday, June 30, 2010 2:16 AM
  • User-1199946673 posted

    In the link I provided earlier this is already explained. More on this:

    http://www.mikesdotnetting.com/Article/78/AccessDataSource-SqlDataSource-and-connecting-to-Access-databases-in-ASP.NET 

    Wednesday, June 30, 2010 3:03 AM
  • User1052662409 posted

    But hans_v where I have hosted my application the service provider doesn't allow to use direct path to connect to the database. They allow us to use database through DSN.

    <asp:AccessDataSource 
    ID="AccessDataSource1"
    runat="server"
    DataFile="~/App_Data/MyDb.mdb" // I need to use DSN instead of direct databse file path(and i am using MSAccess2003)
    SelectCommand="Select * From MyTable">
    </
    asp:AccessDataSource>

    So Does OleDb suppotrs DSN ?

    let me know please

    thanks


    Wednesday, June 30, 2010 5:39 AM
  • User1052662409 posted

    now I changed my code and it's working fine..

    con.Open();
            string strSql = "update tblEnergy set EquipName=?,Potential=?,Advantages=?,Specifications=?,Financial=?,sup1=?,sup2=?,sup3=?,Benifit=? where sno=?";
            OdbcCommand com = new OdbcCommand(strSql,con);
            com.Parameters.Add("EquipName",OdbcType.Text).Value =txtEquipName.Text;
            com.Parameters.Add("Potential",OdbcType.Text).Value= txtPoten.Text;
            com.Parameters.Add("Advantages",OdbcType.Text).Value= txtAdvantages.Text;
            com.Parameters.Add("Specifications",OdbcType.Text).Value= txtSpecific.Text;
            com.Parameters.Add("Financial",OdbcType.Text).Value= txtFinance.Text;
            com.Parameters.Add("sup1",OdbcType.Text).Value= txtSup1.Text;
            com.Parameters.Add("sup2",OdbcType.Text).Value= txtSup2.Text;
            com.Parameters.Add("sup3",OdbcType.Text).Value= txtSup3.Text;
            com.Parameters.Add("Benifit",OdbcType.Text).Value= txtBenifit.Text;
            com.Parameters.Add("sno",OdbcType.Int).Value=lblSno.Text;

    i didnt use AddWithvalue instead I use Add

    there is any issue using like this with odbc where as mikedotnetting's article shows that we shld use AddWithvalue while using ODBC or OleDb

    let me know pls..

    thans


    Thursday, July 1, 2010 5:27 AM
  • User-1199946673 posted

    When using OLEDB I never experienced a problem like this. Since I never use ODBC, I can't say why this is happening. Start replacing Add with AddWithValue one by one, trying to pinpoint which field(s) is (are) causing this problem.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, July 1, 2010 4:29 PM