VB.net - UPDATE query with binary data

Hi, I am trying to update a field in a record of a Access Database
(whose structure I can not modify).

I got this error (translated from italian): "Data types do not match
in the expression" = "Tipi di dati non corrispondenti nell'espressione
criterio."

The code is the following: (myField is a binary field as on Access
2007)

                'determine new value
                Dim newValue() As Byte = ... (valid data)

                'write new attributes
                Dim conn As OleDbConnection = myObj.getConnection
                Dim cmd As OleDbCommand = conn.CreateCommand
                cmd.CommandType = CommandType.Text

                cmd.CommandText = "UPDATE myTable SET myField =
@newValue WHERE fId = @id"

                Dim par As New OleDbParameter("@newValue",
OleDbType.Binary)
                par.Value = newValue
                cmd.Parameters.Add(par)

                cmd.Parameters.Add(New OleDbParameter("@id", ID))

                conn.Open()
                cmd.ExecuteNonQuery()

                conn.Close()

Does anybody know the problem about it?

Thanks,
Sid.

0
SiD
8/30/2007 5:14:18 PM
access.queries 6343 articles. 1 followers. Follow

5 Replies
2604 Views

Similar Articles

[PageSpeed] 36

While I neither use VB.Net, neither this approach in C#, but it seems you 
may use a Large Binary Object data type rather than a bit type. Maybe 
changing

        OleDbType.Binary

to

        GetType(Byte)

would perform better?


Vanderghast, Access MVP


"SiD`" <micheledicosmo@gmail.com> wrote in message 
news:1188494058.361598.153240@r29g2000hsg.googlegroups.com...
> Hi, I am trying to update a field in a record of a Access Database
> (whose structure I can not modify).
>
> I got this error (translated from italian): "Data types do not match
> in the expression" = "Tipi di dati non corrispondenti nell'espressione
> criterio."
>
> The code is the following: (myField is a binary field as on Access
> 2007)
>
>                'determine new value
>                Dim newValue() As Byte = ... (valid data)
>
>                'write new attributes
>                Dim conn As OleDbConnection = myObj.getConnection
>                Dim cmd As OleDbCommand = conn.CreateCommand
>                cmd.CommandType = CommandType.Text
>
>                cmd.CommandText = "UPDATE myTable SET myField =
> @newValue WHERE fId = @id"
>
>                Dim par As New OleDbParameter("@newValue",
> OleDbType.Binary)
>                par.Value = newValue
>                cmd.Parameters.Add(par)
>
>                cmd.Parameters.Add(New OleDbParameter("@id", ID))
>
>                conn.Open()
>                cmd.ExecuteNonQuery()
>
>                conn.Close()
>
> Does anybody know the problem about it?
>
> Thanks,
> Sid.
> 


0
Michel
9/4/2007 2:22:39 PM
Thanks for the reply.
I tried modifying the code, but the error remains the same.

What kind of approach would you use in C#?

Thanks again,
SiD.

On Sep 4, 4:22 pm, "Michel Walsh"
<vanderghast@VirusAreFunnierThanSpam> wrote:
> While I neither use VB.Net, neither this approach in C#, but it seems you
> may use a Large Binary Object data type rather than a bit type. Maybe
> changing
>
>         OleDbType.Binary
>
> to
>
>         GetType(Byte)
>
> would perform better?
>
> Vanderghast, Access MVP
>
> "SiD`" <micheledico...@gmail.com> wrote in message
>
> news:1188494058.361598.153240@r29g2000hsg.googlegroups.com...
>
> > Hi, I am trying to update a field in a record of a Access Database
> > (whose structure I can not modify).
>
> > I got this error (translated from italian): "Data types do not match
> > in the expression" = "Tipi di dati non corrispondenti nell'espressione
> > criterio."
>
> > The code is the following: (myField is a binary field as on Access
> > 2007)
>
> >                'determine new value
> >                Dim newValue() As Byte = ... (valid data)
>
> >                'write new attributes
> >                Dim conn As OleDbConnection = myObj.getConnection
> >                Dim cmd As OleDbCommand = conn.CreateCommand
> >                cmd.CommandType = CommandType.Text
>
> >                cmd.CommandText = "UPDATE myTable SET myField =
> > @newValue WHERE fId = @id"
>
> >                Dim par As New OleDbParameter("@newValue",
> > OleDbType.Binary)
> >                par.Value = newValue
> >                cmd.Parameters.Add(par)
>
> >                cmd.Parameters.Add(New OleDbParameter("@id", ID))
>
> >                conn.Open()
> >                cmd.ExecuteNonQuery()
>
> >                conn.Close()
>
> > Does anybody know the problem about it?
>
> > Thanks,
> > Sid.


0
SiD
9/4/2007 3:34:21 PM
I use an MSDataSetGenerator in general, and, on very few occasions, I 
compose the SQL text of the command itself.


Vanderghast, Access MVP


"SiD`" <micheledicosmo@gmail.com> wrote in message 
news:1188920061.161823.81630@22g2000hsm.googlegroups.com...
> Thanks for the reply.
> I tried modifying the code, but the error remains the same.
>
> What kind of approach would you use in C#?
>
> Thanks again,
> SiD.
>


0
Michel
9/4/2007 5:34:19 PM
Ok, It seems the I resolved it: the problem was about the order in
which the parameters are added.
In access the parameter name does not be evaluated but the order.
Obviously the query is evaluated first in the WHERE clause, so the ID
must be provided first.

On Sep 4, 7:34 pm, "Michel Walsh"
<vanderghast@VirusAreFunnierThanSpam> wrote:
> I use an MSDataSetGenerator in general, and, on very few occasions, I
> compose the SQL text of the command itself.
>
> Vanderghast, Access MVP
>
> "SiD`" <micheledico...@gmail.com> wrote in message
>
> news:1188920061.161823.81630@22g2000hsm.googlegroups.com...
>
> > Thanks for the reply.
> > I tried modifying the code, but the error remains the same.
>
> > What kind of approach would you use in C#?
>
> > Thanks again,
> > SiD.


0
SiD
9/5/2007 9:13:17 AM
I knew that was a problem with ADO, but I was on the impression it was 
'corrected' in ADO.Net.



Vanderghast, Access MVP


"SiD`" <micheledicosmo@gmail.com> wrote in message 
news:1188983597.056972.167060@d55g2000hsg.googlegroups.com...
> Ok, It seems the I resolved it: the problem was about the order in
> which the parameters are added.
> In access the parameter name does not be evaluated but the order.
> Obviously the query is evaluated first in the WHERE clause, so the ID
> must be provided first.
>
> On Sep 4, 7:34 pm, "Michel Walsh"
> <vanderghast@VirusAreFunnierThanSpam> wrote:
>> I use an MSDataSetGenerator in general, and, on very few occasions, I
>> compose the SQL text of the command itself.
>>
>> Vanderghast, Access MVP
>>
>> "SiD`" <micheledico...@gmail.com> wrote in message
>>
>> news:1188920061.161823.81630@22g2000hsm.googlegroups.com...
>>
>> > Thanks for the reply.
>> > I tried modifying the code, but the error remains the same.
>>
>> > What kind of approach would you use in C#?
>>
>> > Thanks again,
>> > SiD.
>
> 


0
Michel
9/5/2007 12:41:09 PM
Reply:

Similar Artilces:

VB distmon?
Hi I have recently installed Office 2003. A couple of wired things happen in Excel: > Everytime I close the program I get a MS VB error that reads "Compile error in hidden module: Distmon" Every time open the program I get the same error, but the macro it is calling is "autoexecnew" > Since my new installation, I type in an simple function like TRIM and it tells me cannot find project library. any ideas? Thnaks! Alan Alan http://support.microsoft.com/default.aspx?scid=kb;EN-US;q307410 OFF: "Compile Error in Hidden Module" Error Message When You Sta...

Query's
Hi. I have encountered the problem of not knowing whether it is possible to assign a macro to a query to change the value it looks for. I currently have a "data entry" sheet that is acting as a day book, and i an "Invoice" sheet acting as a statment page. I would like to create a query to search for a specific value that can be changed, and to search for the amount of "jobs, costs ect." I am finding this very difficult and cannot get it to work. Any help will be greatly appreciated. Cheers Keowaz@hotmail.co.uk ...

Queries
I have created an Access database (2003) that contains information about the status of specific projects our office is working. There is only one table and the database contains the names of about 30 employees. Each employee is assigned specific work and required to input dates regarding the status of each part of the overall process (there are about 5 pieces). Is it possible to create a query where I input the employee's name and a single date criteria (i.e. between 6/13/07 and 6/20/07) and Access will search across multiple fields to return the requested information? For insta...

Copying cell data automatically?
If you want something from cell (A) to appear in cell (B) and be dependent on the first cell, i.e, when cell A text changes so does cell B, how do I do that? It depends You can use an IF statement =IF(A1=1,"Something","SomethingElse") Or if there are many different inputs you can create a table somewhere A One B Two C Three And use VLOOKUP HTH PC "Acurran" <Acurran@discussions.microsoft.com> wrote in message news:50C72329-771C-45E4-8945-E5EB71C5BDCB@microsoft.com... > If you want something from cell (A) to appear in cell (B) and ...

Excel VB
I have two cells in a workbook that are dates. The cell Start_Date has a valid date in it. The second cell Test_Date is either blank or has a valid date in it. The IsDate test on both cells works fine, however, on a blank cell the Month function extracts "12". Anyone know why? I had to put the month function within a test for IsDate to make it work. Seems like Month function on a blank cell should return something other than a 12. Dave Test code: If IsDate(Range("Start_Date")) Then 'Cell has 11/01/09 in it. MsgBox ("start date a d...

Expression with wrong data type message box
I have a form with 2 email addresses in it, the To email addy and the CC email addy. When one of our employees clicks the button to send a report from the form in an email, he gets this message box: "An expression you entered is the wrong data type for one of your arguements" I can't duplicate his problem, but he's still having it. Thank you in advance for any help. Gee Check to see if they have any MISSING references. And, just in case you aren't sure how: http://www.btabdevelopment.com/main/QuickTutorials/Howtocheckformissingreferences/tabid/71/Default.aspx -- ...

Query Question - Friend - Friend - Friend
There are two tables. Table1 has names of all people in town, and Table2 has friend relationship of people in Table1. TABLE 1 | TABLE 2 | NAME | IndexID NAME FRIENDNAME A | 1 A B B | 2 A C C | 3 B A D | 4 B D E | 5 C A F | 6 C E G | 7 D B H | 8 D E | 9 ...

LDAP query based on OU
I'm trying to write a ldap query for a recipient policy. I need to apply the policy on users that are under a specific organizational unit. The only attribues that contain the organizational unit are DistinguishedName and CanonicalName. Is there a way to filter these users or is it still impossible, like Exchange 2000 (http://support.microsoft.com/default.aspx?scid=kb;en-us;296112)? If it's not possible, what can be the best workaround (besides filtering on the Logon Name)? Look for DIRECTORY SERVICES COMMAND and prepare a batch file and boom -- Asif Ali Ansari Exchange Adm...

Cannot Add any window to VB
Hello: I'm using a VM with GP 10.0 SP3 installed. In order to have the same as our production databases i copy the GP folder, entirely, which i think it was a mistake now I'm getting a "This cannot be added to Visual Basic", whenever i try to add a window, any window, to VB. Also it goes without saying that there's a lot of load errors starting GP. For the record the copy/paste thing worked, sort of, and before you start thinking that i was insane to have done this, there's a reason behind it, There's been a lot of tweaks to our production server, by our p...

Migration data CRM 2.0 to CRM 3.0
Hi All, Exist any tool for this? I need to migrate data CRM 2.0 to CRM 3.0... Thanks On 10 jul, 19:56, Vivian Queiroz <vivian_queiro...@hotmail.com> wrote: > Hi All, > Exist any tool for this? I need to migrate data CRM 2.0 to CRM 3.0... Thanks Actually, CRM2.0 does not exist. But if you have CRM 1.2 and you have to migrate your system, the best thing to do is just upgrade the system. If you really want to transfer the data, then there are various import tools. Some form microsoft, some from third parties. You can find all third party tools on www.pimpmycrm.com Regards, Hi, T...

data selected is not what appears on the chart
I am trying to change the range of data but the information I am selecting is not what is showing up on the chart. Right-click on the chart, and select "Source Data". Look at what is in your data series. -- David Biddulph "JJ" <JJ@discussions.microsoft.com> wrote in message news:2730EF4A-9575-41D5-958F-9C360CFAF4EA@microsoft.com... >I am trying to change the range of data but the information I am selecting >is > not what is showing up on the chart. ...

Download NET 3.5 Sp1 Service Pack
I can't download the NET 3.5 Service Pack3 or Service Pack 2. I have XP They do not exist - there is only Dot Net Fx 3.5 SP1. "marlsrsoftball" <marlsrsoftball@discussions.microsoft.com> wrote in message news:49BC29A3-F9B1-430B-B5EE-C4DA5B6C0E95@microsoft.com... >I can't download the NET 3.5 Service Pack3 or Service Pack 2. > > I have XP What it is saying ".NET 3.5 Service Pack 1 Framwork not installed when I try to dowload it i get an Error Code: 0x80070645 Fred "Jerry" wrote: > They do not exist - there is...

Free Workshop on .NET and Programming Solutions by Dr. Venkat
Those of us programming on the .NET framework have come to realize the power and increased productivity that comes with it, says Dr. Venkat Submramaniam. Like any development, however, there are things that one should pay attention to while programming on .NET. Are there things in .NET that, if we do not pay attention to, may result in more trouble than it is worth? Learn all there is to know in a FREE video workshop conducted by Dr. Venkat Subramaniam. In the workshop recorded at Saltmarch Media's Great Indian Developer Summit, Venkat presents Gotchas that a developer needs ...

Database-Query and AutoFill??????
Hi, In an Excel 2003 table there are 2 coloumns that contain values, which are also contained as values in an ODBC-database. In the third coloumn I'd like to have further values, that belong to the values of coloumn 1 and 2. These values should come from the database. There for I made a query (Data, import external Data, new query ....) with two parameters, which I've linked with the first two cells. This works fine in the first line of the table. Is there any possibility to complete the third coloumn using AutoFill, so that I get the value that belongs to the values of coloumn 1...

Query cannot be completed
I recently had a problem on my Microsoft Access database. "The query cannot be completed. Either the size of the query result is larger than the maximum size of the database (2GB) or there is not enough temory storage space on the disk to store the query result" I have an Dell Optiplex 755 running Windows XP Professional with 2GB of ram and running Access 2007. 1. Do a Compact and Repair of the database file. Using something like Windows Explorer see what the file size is after compacting. 2. Run the query again. See what the size is afterwards or after it quits. Is is nea...

Public folder query
Hi all, We have 4 Exchange servers running Windows 2003 Server and Exchange 2003. They are all at different offices and connected across a VPN. In the offices Outlook 2003 is used by the users for email and public folder access. Everyone in the these offices can access all public folders. OWA is used for users outwith the offices. User connect to their relevant exchange server with the following URLs: http://server1.domain.co.uk/exchange http://server2.domain.co.uk/exchange http://server3.domain.co.uk/exchange http://server4.domain.co.uk/exchange Users that connect to server1 can access ...

Help with adding data in a column
I get a datafeed emailed each day. When it comes i have to edit the last column in this case colunm "D" and "E" to include the number "2" next to every row, I manually copy and drag down this every day. The problem i have is every day it come with different rows numbers , some days its over 1000 rows next day it can be 400 is there anyway i can put a Macro formula in place so i don't have to manaully do this every single day. Paul Hi Lenny, You can simulate, the fill-handle copy down with Fill-Handle, Replication and use of the Mouse Filldown...

vb from VC++
Hi, is it possible, and if so, to call a Vb macro from VC++. Or manipulate spreadsheets (ie draw graphs from the data within the workbooks) usinbg MFC functions cheers Anthony Presumably you are referring to MS Excel spreadsheets and workbooks. The easiest method would be to import the appropriate type library (.tlb) provided with Excel, having the class wizard generate the classes, which you then use to access the Excel Automation model (that is the same model that Excel VBA uses). Some investigation may be needed to determine which tlb to use, and to make sure you have a basic understand...

VB in Excel
In Excel I go into Visual Basic Editor, then Visual Basic Help, but when I type 'Passwords' for example it will bring up a list of related items, but some of them you can't select. Does this mean the installation CD is corrupt and hasn't installed all the components? I have reinstalled and repaired the installtion but to no avail. Any ideas anyone? Help! Thanks ...

How to show data between two dates?
I have a list of tenants and the dates they moved in and out of their flats. I need to show which weeks within a specific period that the flats were filled - either by showing the tenants intials or a tick. A B C D E F G H Unit No Client Start End 04-01 11-01 18-01 25-01 1 JB 23-11 06-02 JB 2 GK 05-01 GK GK GK GK 3 LB 01-12 28-02 LB LB LB LB Does anybody know how is best to do this? We've tried using an IF formula but it doesn't work if their is a start and end date. ...

Query running slow
Hi All, I have got a query with 7-8 tables. Some of them are linked from SQL server and some of them are local Access table. I just updated this query and added another creteria and it became very slow (about 10 minutes) to return the result. If I remove one of the local table, it just needs around 5-8 seconds. But I do need this table in the query. There are three fields in the table, one of Number type field is primary key. The creteria is nothing to do with the fields in the local table. What's the possible reason for that? Any help will be appreciated. Thanks Dani...

VB.Net program to create XML file
I need to create an xml file from a VB program using fields returned from an sql query. I have a template that was provided for me and need to use verbatim. Since this is just a text file, I gather that I can just write out the file with all of the tags, etc., and name it .xml. Assuming that is correct what I might want to do is create a template so that if this file changes the names of the elements, all I have to do is change the template and if more elements get added I can then add them. Is there a tool that can do this for me? If I have to create one, any suggestions as to what I ...

VB++ Exe zum Ansprechen einer VB ActiveX DLL
Hallo zusammen. Ich ben�tige eine EXE, welche in einer DOS-Box mit Parametern aufgerufen wird und das Ergebnis auch wieder in dieser DOS-Box zur�ckbringt. Mit VB ist dies leider nicht zu machen. Nun weiss ich zwar das dies mit einer VC++ Exe geht, bin aber leider C Neuling. Kann mir dazu jemand ein Beispiel posten ? Die C++ Exe soll einen auf der Commandozeile �bergebenen String (das sind die ganzen Parameter) an eine Funktion einer VB ActiveX DLL �bergeben. Das Ergebnis soll dann von der ActiveX DLL an die C++ Exe zur�ckgegeben werden und in der selben DOS-Box angezeigt werden. Hoffe es k...

Query as Pop Up, is it possible?
Hello there! Is there an option, or how can I run a Query as Pop up mode? What I want is that the user can see the results in Crosstab query but I want they do not have access to see the query in design mode neither make changes, I would like a pop up query but not a maximized window and the only option that the user can see is the Close Botton, and another button to print the query, is it possible? Note: using sub-form does not work since in the crosstab appear some main field that when the sub-form was built they were not there, and this cause the sub-form show an error because th...

VB Script
Hi all, I need a VB script code to verify whether a specific Local user ID on a remote machine, in workgroup, is having a specific password. For instance I need to check whether target machine consists a local user "DSADMIN" 's password set to "Pa55word". If the target machine consists this user account and the password is also correct then it should return TRUE else it should return FALSE (or something similar). Below code tries to reset the password on target machine by providing same old and new password, if it fails that means the password set on target...