Questions tagged [oledbparameter]

23 questions
11
votes
2 answers

OleDbParameters and Parameter Names

I have an SQL statement that I'm executing through OleDb, the statement is something like this: INSERT INTO mytable (name, dept) VALUES (@name, @dept); I'm adding parameters to the OleDbCommand like this: OleDbCommand Command = new…
Gaz
  • 3,855
  • 6
  • 28
  • 33
5
votes
3 answers

C# Access OleDb Data type mismatch in criteria expression

Would you please kindly check the following code for errors that give me a 'Data type mismatch in criteria expression' exception? I just can't seem to find the source of the problem... *record.Date of nullable DateTime? type is explicitly casted to…
MooMooCoding
  • 319
  • 1
  • 5
  • 15
3
votes
3 answers

Passing a DateTime value as a parameter to an OleDbCommand

I have a problem passing a DateTime value to a query as a DbParameter. It seems the time part of the DateTime value gets stripped away. Here is a sample code in C#: DbProviderFactory _factory = OleDbFactory.Instance; DbCommand cmd =…
Gerardo Contijoch
  • 2,421
  • 5
  • 20
  • 29
3
votes
3 answers

The OleDbParameter's name obsession

Since the OleDbParameter does not use named parameters (due to its nature), why is it that the .NET OleDbParameter class expects a name? (string parametername ...) All constructors require a parameter name, and I'm never sure what name to give it;…
emre
2
votes
3 answers

Using Parameters with OleDbDataAdapter in C#

I'm using OleDb to populate a DataTable. I'm trying to use a parameterized query, but it doesn't seem to work with a OleDbDataAdapter. Anyone have any suggestions? cmd.CommandText = "SELECT A,B,C,D FROM someTable WHERE A=@A AND D BETWEEN @D1 AND…
Dan Champagne
  • 890
  • 2
  • 17
  • 37
2
votes
1 answer

C# OleDbParameter with Access DateTime query

I have the following query that works from inside Access or from C# as an OleDbCommand: SELECT Table1.ProductType, Sum(Table1.ProductsSold) FROM Table1 WHERE (Table1.DateTime Between #5/16/2013# And #5/17/2013#) GROUP BY…
Derek Johnson
  • 927
  • 1
  • 11
  • 15
1
vote
1 answer

OleDb Parameters Array Format

Hi in the OleDB documentation (linked below) they have a parameter called OleDbParameter[] parametersin a functions, a loop then iterates over that array to insert the parameters into the SQL. I can't find in the documentation how you are supposed…
Oliver Guy
  • 71
  • 8
1
vote
1 answer

Oledb update-command with parameters not working on access-db

I have a problem in my c#-application. I try to update an access-database via oledb-connection. Here is the schema of the table: Here is the function i am using: public override int Update(string tableName, Action
Olli
  • 658
  • 5
  • 26
1
vote
2 answers

Cannot Get Value When OleDbParameter Used

It is not good form to create a query like let fnam_query = "select * from file_name_info where fnam_origin = 'invoice_cloud'" But the code block below has two problems. First, the fnam_readOk returns false from the read. Second, how can the…
octopusgrabbus
  • 10,555
  • 15
  • 68
  • 131
1
vote
1 answer

Clearing OleDbDataReader parameters

In order to do my stuff, I query the database (Access) to see if my data is already there. So, I'm using a OleDbDataReader. Everything is fine at this moment. Next, depending on the result of my query, I'm doing an insert or and update. The problem…
esylvestre
  • 1,850
  • 4
  • 21
  • 30
1
vote
1 answer

Inserted fields in the wrong place in the table C# OleDB

I'm making a successfull Insert into the table, but for some reason the fields are in a messed up position. Working on Visual Studio 2012 C# with an MS Access Database 2010. (Don't have enough rep to post imagens directly so please bear with the…
1
vote
2 answers

Pass a SQL condition as a OleDb parameter

I have following code: Dim executedCmd As OleDb.OleDbCommand = m_dbMgr.GetCommand() executedCmd.CommandText = "select * from [Parameters] where " Dim SQLcondition As String = String.Empty For i As Integer = 0 To ParameterName.Count - 1 …
1
vote
3 answers

pass null parameter to SQL server query

How can I pass a null parameter to a SQL server query. I have a simple table with a nullable int column. If I pass a .NET null value, I get a sql error. If I pass DBNull.Value, no row matches the filter. Is there a simple way to do this without…
tom7
  • 4,062
  • 8
  • 30
  • 30
0
votes
2 answers

Updating datetime in access table

I'm trying to insert a datetime value into a datatable and then use the oledbdataadapter's update(datatable) method to load it into my database.. but i keep getting a "Data type mismatch in criteria expression." error. My access Data types in the…
user1181589
  • 153
  • 1
  • 10
0
votes
4 answers

Null Reference Exception

This code generates and Null Reference exception. Exception comes at the line where the parameter array is initialized. What can be the problem? I don't know howto follow the stack-trace and work any logic over it. thanks in advance. DAL dal…
emre
1
2