Re: Newbie SQL Queston on INSERT
From: Mark J. McGinty (mmcginty_at_spamfromyou.com)
Date: 03/18/05
- Previous message: Chaim: "RE: Newbie SQL Queston on INSERT"
- In reply to: Chaim: "RE: Newbie SQL Queston on INSERT"
- Next in thread: Dennis: "Re: Newbie SQL Queston on INSERT"
- Reply: Dennis: "Re: Newbie SQL Queston on INSERT"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 18 Mar 2005 11:11:02 -0800
It's also a little surprising that he ends up with 'str' as the field's
value, something must be interpolating it before passing it to SQL,
otherwise it should throw an error. In QA I get:
The name 'str' is not permitted in this context. Only constants,
expressions, or variables allowed here. Column names are not permitted.
Further, STR is a built-in function, but without parens apparently that does
not come into play.
-Mark
"Chaim" <Chaim@discussions.microsoft.com> wrote in message
news:98FF29E5-8D05-4E9A-8CA0-17BD7FCF340C@microsoft.com...
> I'm also not sure about the 'new' in your initialization of str. It seems
> that it should probably just read:
> dim str as string = "First Record"
>
> But that's just my guess from reading the grammar and following the links
> in
> the VB.NET Language Spec. The 'New' seems to be used to create a new
> object
> reference. You aren't creating a new object, just assigning a literal.
>
> "Dennis" wrote:
>
>> I am trying to get my SQL statement correct for inserting data into a
>> column
>> using a string variable in VB.Net. Following is my code:
>>
>> dim str as string = new "First Record"
>> DBCmd.CommandText = "INSERT INTO Items (Title) VALUES (str)"
>> DBCmd.ExecuteNonQuery()
>>
>> The value it puts into the Title Field is "str" not "First Record". What
>> am
>> I doing wrong?
>> --
>> Dennis in Houston
- Previous message: Chaim: "RE: Newbie SQL Queston on INSERT"
- In reply to: Chaim: "RE: Newbie SQL Queston on INSERT"
- Next in thread: Dennis: "Re: Newbie SQL Queston on INSERT"
- Reply: Dennis: "Re: Newbie SQL Queston on INSERT"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
|