473,386 Members | 1,741 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Enterprise Library Data Block : GenericDatabase class and Access databases : Using ExecuteNonQuery problems with parameters

Using Enterprise Library 2.0 (Jan 06) and .NET 2.0 (VB.Net 2005)

Dim dbPF As Data.Common.DbProviderFactory
Try
dbPF =
Data.Common.DbProviderFactories.GetFactory("System .Data.OleDb")

db = New
Microsoft.Practices.EnterpriseLibrary.Data.Generic Database( _
"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=NotesManagerServer.mdb", dbPF)

db.CreateConnection()

Catch ex As Exception
MsgBox("Could not connect to system database. Application
terminating.")
End

I have a Select query in the Access database, named GetFileList and
here is the SQL copied from Access:

SELECT FileList.SrNo, FileList.Filename, FileList.CRC32,
FileList.Timestamp
FROM FileList;

This code works just FINE:

Try
Dim rs As Data.DataSet
rs =
db.ExecuteDataSet(System.Data.CommandType.StoredPr ocedure,
"GetFileList")
DataGridView1.DataSource = rs
DataGridView1.DataMember = rs.Tables(0).ToString

Catch ex As Exception
MsgBox("Exception occured" + ex.Message)

End Try

I have a Update query in the Access database, is named InsertFile and
here is the SQL copied from Access:

PARAMETERS Filename Text ( 255 ), CRC32 Long, [Timestamp] Long;
INSERT INTO FileList ( Filename, CRC32, [Timestamp] )
VALUES (@Filename, @CRC32, @Timestamp);

To run this query in VB.Net, I have this code that WORKS:

Dim p(2) As Data.Common.DbParameter

p(0) = New Data.OleDb.OleDbParameter
p(1) = New Data.OleDb.OleDbParameter
p(2) = New Data.OleDb.OleDbParameter

p(0).Value = "ASDF"
p(1).Value = 11
p(2).Value = 22

Dim cmd As System.Data.Common.DbCommand
cmd = db.GetStoredProcCommand("InsertFile")
cmd.Parameters.Add(p(0))
cmd.Parameters.Add(p(1))
cmd.Parameters.Add(p(2))
cmd.Connection = db.CreateConnection
cmd.Connection.Open()

cmd.ExecuteNonQuery()

My problem is that it looks so 'inelegant' and probably is. How can I
run the Access query using just the db object .. as in
db.ExecuteNonQuery ... I've tried various combinations and I get
various errors regarding parameter discovery ...

Anyone?

I just want to use the db object (GenericDatabase) to run the Insert
query.. with parameters...

Thanks in advance.
ND

Mar 5 '07 #1
0 3823

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

Similar topics

1
by: Mike Chamberlain | last post by:
Hi all. I'm trying to extend the Microsoft Enterprise Library Data Access Application Block (http://msdn.microsoft.com/library/en-us/dnpag2/html/daab.asp?frame=true) to work with a Borland...
43
by: Steven T. Hatton | last post by:
Now that I have a better grasp of the scope and capabilities of the C++ Standard Library, I understand that products such as Qt actually provide much of the same functionality through their own...
0
by: ad | last post by:
I have used Data Application Access Block2 in my web application. Now I download the Library Data Access Application Block. and read the document. May be I am stupid, I can't migrate it to...
1
by: dhussong | last post by:
I am attempting to use Visual Studio 2005 (Visual Basic) and the Enterprise Library 2.0 Data Access Application Block with a Microsoft Access database. I know the names of my Access databases but I...
7
by: galico | last post by:
Hi All, We are having a very strange problem with the above. We have designed an application in ASP.NET 2.0 that uses the enterprise library data application blocks amongst others. We seem to be...
0
by: TattedProgrammer | last post by:
Hello All, I am completely stuck, I have tried for an entire day to get a simple procedure call to my Oracle Db via the enterprise Library 06. I am not an oracle fan to start, but have to deal...
1
by: rockdale | last post by:
Well, I guess I did express myself very clearly. I implemented the Ent Lib 2.0 data block against SQL database successfully. The system now is a production system. But now we want to migrate the...
3
by: shapper | last post by:
Hello, Could someone tell me how to run a simple SQL stored procedure using the Enterprise Library 2.0 Data Access? I have in my VB.NET code the following database: Dim db As Database =...
1
by: nostradumbass77 | last post by:
How do I run a query in access using GenericDatabase class ? I get an error about parameter discovery not allowed when i run ExecuteNonQuery..
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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
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...

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.