473,398 Members | 2,212 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,398 software developers and data experts.

What is wrong in this code line?

Hello,

I am adding a parameter, with only one code line, when I set a
connection to an Access database:

With dbCommand.Parameters

.Add(New System.Data.OleDb.OleDbParameter("@title",
OleDbType.VarWChar).Value = "Title Text")

End With

I get the error: "The OleDbParameterCollection only accepts non-null
OleDbParameter type objects, not Boolean objects."

Why is that?
I have been searching for the solution in Google and I can't see why
this is not working.

Thanks,
Miguel

Nov 19 '05 #1
4 1238
Your vb.net syntax is all messy.

you have .Add( <CODE HERE > )

your <CODE HERE> looks like:

New System.Data.OleDb.OleDbParameter("@title", OleDbType.VarWChar).Value =
"Title Text"

which, I guess, is doing an equallity operartion, instead of an assignment.
That is, it's checking if
New System.Data.OleDb.OleDbParameter("@title", OleDbType.VarWChar).Value
IS EQUAL TO
"Title Text"

and return false...hence why it's saying you can't add false to .Add()

It should look like:

..Add(New System.Data.OleDb.OleDbParameter("@title",
OleDbType.VarWChar)).Value = "Title Text"

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Shapper" <mdmoura*NOSPAM*@gmail.*DELETE2SEND*com> wrote in message
news:eG**************@tk2msftngp13.phx.gbl...
Hello,

I am adding a parameter, with only one code line, when I set a connection
to an Access database:

With dbCommand.Parameters

.Add(New System.Data.OleDb.OleDbParameter("@title",
OleDbType.VarWChar).Value = "Title Text")

End With

I get the error: "The OleDbParameterCollection only accepts non-null
OleDbParameter type objects, not Boolean objects."

Why is that?
I have been searching for the solution in Google and I can't see why this
is not working.

Thanks,
Miguel

Nov 19 '05 #2

"Shapper" <mdmoura*NOSPAM*@gmail.*DELETE2SEND*com> wrote in message
news:eG**************@tk2msftngp13.phx.gbl...
Hello,

I am adding a parameter, with only one code line, when I set a connection
to an Access database:

With dbCommand.Parameters

.Add(New System.Data.OleDb.OleDbParameter("@title",
OleDbType.VarWChar).Value = "Title Text")

End With

I get the error: "The OleDbParameterCollection only accepts non-null
OleDbParameter type objects, not Boolean objects."

Why is that?
I have been searching for the solution in Google and I can't see why this
is not working.


Because

.Add(New System.Data.OleDb.OleDbParameter("@title",
OleDbType.VarWChar).Value = "Title Text")

is the same as

dim p as New System.Data.OleDb.OleDbParameter("@title", OleDbType.VarWChar)
dim b as Boolean = (p.Value = "TitleText")
..Add(b);

David
Nov 19 '05 #3
New System.Data.OleDb.OleDbParameter("@title", OleDbType.VarWChar).Value =
"Title Text"

is a boolean expression that returns true if New
System.Data.OleDb.OleDbParameter("@title", OleDbType.VarWChar).Value is
equal "Title Text" and false otherwise.

Eliyahu

"Shapper" <mdmoura*NOSPAM*@gmail.*DELETE2SEND*com> wrote in message
news:eG**************@tk2msftngp13.phx.gbl...
Hello,

I am adding a parameter, with only one code line, when I set a
connection to an Access database:

With dbCommand.Parameters

.Add(New System.Data.OleDb.OleDbParameter("@title",
OleDbType.VarWChar).Value = "Title Text")

End With

I get the error: "The OleDbParameterCollection only accepts non-null
OleDbParameter type objects, not Boolean objects."

Why is that?
I have been searching for the solution in Google and I can't see why
this is not working.

Thanks,
Miguel

Nov 19 '05 #4
Hi Karl,

I had tried that before but I get this error message:
error BC30456: 'Value' is not a member of 'Integer'

In Visual Studio the part
With dbCommand.Parameters
.Add(New System.Data.OleDb.OleDbParameter("@title",
OleDbType.VarWChar)).Value
End With

Is underlined and associated with that error.

Any idea?

"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:karl REMOVE @ REMOVE openmymind REMOVEMETOO .
ANDME net:
Your vb.net syntax is all messy.

you have .Add( <CODE HERE > )

your <CODE HERE> looks like:

New System.Data.OleDb.OleDbParameter("@title", OleDbType.VarWChar).Value =
"Title Text"

which, I guess, is doing an equallity operartion, instead of an assignment.
That is, it's checking if
New System.Data.OleDb.OleDbParameter("@title", OleDbType.VarWChar).Value
IS EQUAL TO
"Title Text"

and return false...hence why it's saying you can't add false to .Add()

It should look like:

.Add(New System.Data.OleDb.OleDbParameter("@title",
OleDbType.VarWChar)).Value = "Title Text"

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Shapper" <mdmoura*NOSPAM*@gmail.*DELETE2SEND*com> wrote in message
news:eG**************@tk2msftngp13.phx.gbl...
Hello,

I am adding a parameter, with only one code line, when I set a connection
to an Access database:

With dbCommand.Parameters

.Add(New System.Data.OleDb.OleDbParameter("@title",
OleDbType.VarWChar).Value = "Title Text")

End With

I get the error: "The OleDbParameterCollection only accepts non-null
OleDbParameter type objects, not Boolean objects."

Why is that?
I have been searching for the solution in Google and I can't see why this
is not working.

Thanks,
Miguel


Nov 19 '05 #5

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

Similar topics

1
by: learningGuy | last post by:
Can someone tell me what is wrong with this simple code? I get an exception every time at the myFile.Open() line. I have included the code that I think is needed to for you to answer this below:...
125
by: Sarah Tanembaum | last post by:
Beside its an opensource and supported by community, what's the fundamental differences between PostgreSQL and those high-price commercial database (and some are bloated such as Oracle) from...
72
by: E. Robert Tisdale | last post by:
What makes a good C/C++ programmer? Would you be surprised if I told you that it has almost nothing to do with your knowledge of C or C++? There isn't much difference in productivity, for...
1
by: Qiangning Hong | last post by:
I decide to seperate my data collection routine from my data analysis and storage program to a seperate process, so I try to use the new subprocess model in Python 2.4. The main program spawns...
121
by: typingcat | last post by:
First of all, I'm an Asian and I need to input Japanese, Korean and so on. I've tried many PHP IDEs today, but almost non of them supported Unicode (UTF-8) file. I've found that the only Unicode...
51
by: WindAndWaves | last post by:
Can anyone tell me what is wrong with the goto command. I noticed it is one of those NEVER USE. I can understand that it may lead to confusing code, but I often use it like this: is this...
15
by: ben | last post by:
this programme from sedgewick's 'algorithms in c parts 1-4' "is a sample client program that ... uses a symbol table to find the distinct values in a sequence of keys (randomly generated or read...
10
by: Enkidu | last post by:
Beginner question, sorry! I am using indexers to access an array of StringBuilders in an instance of a class: Getting: value = board1; Setting: board1 = value1 ;
6
by: Kid Programmer | last post by:
Hello guys. I have a question. What's wrong with my compiler. In a simple number averaging program in a GUI window have way into the project I compile the program and I get the following errors: ...
4
by: hirsh.dan | last post by:
i have a functions that writes information to a file. inside that function i have a line in which i call another function. if this line is executed, nothing is written to the file, but if i remark...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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,...

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.