473,513 Members | 2,678 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ERROR: [ODBC Microsoft Access Driver]Invalid precision value

Dear All:
I have been developing ASP.NET application on MS Access database using ODBC.
When I was trying to save more than 255 chars in a Memo field I got the
following error.
ERROR [HY104] [Microsoft][ODBC Microsoft Access Driver]Invalid precision
value

Below is the code snippet of two function where it is breaking. Any advice
on this would be greatly appreciated.

----CODE BEGIN---
public static int ExecuteNonQuery(string connString, string cmdText, params
object[] parameterValues)
{
OdbcConnection conn = new OdbcConnection(connString);
conn.Open();
OdbcCommand cmd = new OdbcCommand(cmdText, conn);
if ((parameterValues != null) && (parameterValues.Length > 0))
{
AssignParameterValues(cmd, parameterValues);
}
// GOT THE FOLLOWING ERROR WHILE EXECUTING THE UPDATE QUERY WITH MORE THAN
256 CHARS FOR MEMO FIELD
// ERROR [HY104] [Microsoft][ODBC Microsoft Access Driver]Invalid precision
value
int nRowsAffected = Convert.ToInt32(cmd.ExecuteNonQuery());
conn.Close();
return nRowsAffected;

}

private static void AssignParameterValues(OdbcCommand cmd, object[]
parameterValues)
{
if (parameterValues == null)
{
return;
}
for (int i = 0, j = parameterValues.Length; i < j; i++)
{
cmd.Parameters.Add(new OdbcParameter("@"+i,parameterValues[i]));
}
return;
}
----CODE END ----

Thank you so much and looking forward to your kind response.

Reza.
Nov 19 '05 #1
1 8318
On Thu, 8 Sep 2005 13:50:05 -0700, Reza Nabi <rn***@hotmail.com> wrote:

¤ Dear All:
¤ I have been developing ASP.NET application on MS Access database using ODBC.
¤ When I was trying to save more than 255 chars in a Memo field I got the
¤ following error.
¤ ERROR [HY104] [Microsoft][ODBC Microsoft Access Driver]Invalid precision
¤ value
¤
¤ Below is the code snippet of two function where it is breaking. Any advice
¤ on this would be greatly appreciated.
¤
¤ ----CODE BEGIN---
¤ public static int ExecuteNonQuery(string connString, string cmdText, params
¤ object[] parameterValues)
¤ {
¤ OdbcConnection conn = new OdbcConnection(connString);
¤ conn.Open();
¤ OdbcCommand cmd = new OdbcCommand(cmdText, conn);
¤ if ((parameterValues != null) && (parameterValues.Length > 0))
¤ {
¤ AssignParameterValues(cmd, parameterValues);
¤ }
¤ // GOT THE FOLLOWING ERROR WHILE EXECUTING THE UPDATE QUERY WITH MORE THAN
¤ 256 CHARS FOR MEMO FIELD
¤ // ERROR [HY104] [Microsoft][ODBC Microsoft Access Driver]Invalid precision
¤ value
¤ int nRowsAffected = Convert.ToInt32(cmd.ExecuteNonQuery());
¤ conn.Close();
¤ return nRowsAffected;
¤
¤ }
¤
¤ private static void AssignParameterValues(OdbcCommand cmd, object[]
¤ parameterValues)
¤ {
¤ if (parameterValues == null)
¤ {
¤ return;
¤ }
¤ for (int i = 0, j = parameterValues.Length; i < j; i++)
¤ {
¤ cmd.Parameters.Add(new OdbcParameter("@"+i,parameterValues[i]));
¤ }
¤ return;
¤ }
¤ ----CODE END ----
¤

I would highly recommend you use the Jet OLEDB provider and the .NET OLEDB namespace instead. The
following works for me:

Sub WriteMemoToAccess()

Dim AccessConnection As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; " & _
"Data Source=e:\My Documents\db1.mdb")
Dim AccessCommand As New OleDbCommand("UPDATE Table1 SET MemoField=? WHERE [record id] = 1",
AccessConnection)
Dim StringValue As String = "Very long text...................."
Dim QueryParameter As New OleDbParameter("@LongText", OleDbType.LongVarWChar,
Len(StringValue), ParameterDirection.Input, False, 0, 0, Nothing, DataRowVersion.Current,
StringValue)
AccessCommand.Parameters.Add(QueryParameter)
AccessConnection.Open()
AccessCommand.ExecuteNonQuery()
AccessConnection.Close()

End Sub
Paul
~~~~
Microsoft MVP (Visual Basic)
Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
31007
by: Krung Saengpole | last post by:
Hi, I used SQL Server 2000 Personal Edition. I created a stored procedure having input parameters as smallint,tinyint,char,varchar and smalldatetime. When I executed it by Query Analyzer, it's...
1
9459
by: Tim Groulx | last post by:
Hello All, I am getting the following error when attemping to open a table in SQL2kSP3a. ________________________________________ SQL Server Enterprise Manager Database Server: Microsoft SQL...
10
20962
by: FreeOperator | last post by:
Dear all, On Win2000 server with SP3, I am trying to access a SQL Server 7.0 database, "TestDB", from VB6 via a SQL Server ODBC system DSN using ADO 2.7. In SQL Server Enterprise Manager, there...
0
704
by: Darryl | last post by:
I am receiving this error when try to insert a value into the Summary field that is formatted in HTML. I am using ASP to connect to an Access database. The ASP code for the insert statement is as...
8
40619
by: Dakkar | last post by:
I wrote a program with c# for connecting mysql and taking data from it but when someone without me try to execute the program they are taking this error ERROR Data source name not found and...
0
5884
by: jwtulp | last post by:
Hello all, I receive the following error when updating MSAccess2003 Memo fields using an ODBC connection in ASP.Net 1.1 when the length of the text to be updated exceeds 255 characters....
1
3869
by: mudasserrafiq | last post by:
I am using following asp file default.asp <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <META http-equiv=Content-Type content="text/html; charset=windows-1252"> <META content="0...
1
2405
by: ashutoshvyas | last post by:
Hello All. Specially ADejii. I had generated a report in VB. For that purpose i am using ACCESS database. This database is connected via Microsoft Jet 4.0 OLE DB provider, and it is working well....
0
1842
by: calvinkwoo3000 | last post by:
My Window application run property withour link to mdb without password. Once i set security password to mdb file, the error belor come out when i click detail. Not a valid password. and detail...
0
7379
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7535
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7521
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5682
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5084
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4745
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3232
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3221
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1591
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.