Showing posts with label variables. Show all posts
Showing posts with label variables. Show all posts

Monday, February 13, 2012

Adding column problem

I consulted the SQL2K help for adding a table and copied the code and
substituted my own variables, but I get an error message about incorrect
syntax regarding the AS in line 1. I'm a newbie and am bummed that the code
provided in the help doesn't work--I'm assuming there's something I don't
know here. Here's the code:
---
Dim t_AssessmentItem As SQLDMO.Table
Dim OutputAssessmentLevelID As New SQLDMO.Column
OutputAssessmentLevelID.Name = "ShelfLife"
OutputAssessmentLevelID.Datatype = "CodeID"
OutputAssessmentLevelID.AllowNulls = False
OutputAssessmentLevelID.DRIDefault.Int = "AssessmentLevelID"
Set t_AssessmentItem = _
oSQLServer.Databases("PowerSuasionDevLocal").Tables("t_AssessmentItem")
t_AssessmentItem.BeginAlter
t_AssessmentItem.Columns.Add OutputAssessmentLevelID
t_AssessmentItem.DoAlter
--
Thanks for your help,
karolus> OutputAssessmentLevelID.DRIDefault.Int = "AssessmentLevelID"
I don't see an Int property for the DRIDefault object. You might try
specifying a default constraint name and value instead. For example:
OutputAssessmentLevelID.DRIDefault.Name = "DF_t_AssessmentItem_ShelfLife"
OutputAssessmentLevelID.DRIDefault.Text = "0"
Hope this helps.
Dan Guzman
SQL Server MVP
"Karolus" <Karolus@.discussions.microsoft.com> wrote in message
news:DA68ACB7-098B-4282-92C6-23A24E024C1B@.microsoft.com...
>I consulted the SQL2K help for adding a table and copied the code and
> substituted my own variables, but I get an error message about incorrect
> syntax regarding the AS in line 1. I'm a newbie and am bummed that the
> code
> provided in the help doesn't work--I'm assuming there's something I don't
> know here. Here's the code:
> ---
> Dim t_AssessmentItem As SQLDMO.Table
> Dim OutputAssessmentLevelID As New SQLDMO.Column
> OutputAssessmentLevelID.Name = "ShelfLife"
> OutputAssessmentLevelID.Datatype = "CodeID"
> OutputAssessmentLevelID.AllowNulls = False
> OutputAssessmentLevelID.DRIDefault.Int = "AssessmentLevelID"
> Set t_AssessmentItem = _
> oSQLServer.Databases("PowerSuasionDevLocal").Tables("t_AssessmentItem")
> t_AssessmentItem.BeginAlter
> t_AssessmentItem.Columns.Add OutputAssessmentLevelID
> t_AssessmentItem.DoAlter
> --
> Thanks for your help,
> karolus|||"Karolus" <Karolus@.discussions.microsoft.com> wrote in message
news:DA68ACB7-098B-4282-92C6-23A24E024C1B@.microsoft.com...
> I consulted the SQL2K help for adding a table and copied the code
and
> substituted my own variables, but I get an error message about
incorrect
> syntax regarding the AS in line 1. I'm a newbie and am bummed that
the code
> provided in the help doesn't work--I'm assuming there's something I
don't
> know here. Here's the code:
> ---
> Dim t_AssessmentItem As SQLDMO.Table
> Dim OutputAssessmentLevelID As New SQLDMO.Column
> OutputAssessmentLevelID.Name = "ShelfLife"
> OutputAssessmentLevelID.Datatype = "CodeID"
> OutputAssessmentLevelID.AllowNulls = False
> OutputAssessmentLevelID.DRIDefault.Int = "AssessmentLevelID"
> Set t_AssessmentItem = _
>
oSQLServer.Databases("PowerSuasionDevLocal").Tables("t_AssessmentItem"
)
> t_AssessmentItem.BeginAlter
> t_AssessmentItem.Columns.Add OutputAssessmentLevelID
> t_AssessmentItem.DoAlter
> --
> Thanks for your help,
> karolus
Karolus,
You say your problem is about "incorrect syntax regard the AS in line
1".
It looks like you are using VB/VBA. Have you set a reference to the
"Microsoft SQLDMO Object Library"?
If you haven't, then "SQLDMO.Column" will not work.
Check:
VBA = Tools > References
VB = Project > References
Sincerely,
Chris O.

Adding C++ var into db

Since the SQL server doesn't have visibility to internal
C++ variables in an application, the variables need to be
passed to the server somehow. There are a variety of ways
of doing this including converting the value to text and
stuffing it in the query string. A better way is to use
the API's parameter passing functions (i.e. for ODBC this
is SQLBindParameter).
Cheers
Mitch vH
Microsoft Consulting

>--Original Message--
>What is the syntax of adding C++ variables into SQL
Server/mySQL?
>Could anyone raise an example?
>I've tried
>insert into aTable (field1, field2) values (variable1,
variable2)
>But mySQL throws error messages at me saying varible1 is
not in the field
>list. Haven't tried it yet for SQL Server..
>Thanks for your attention
>Jack
>
>.
>
Hi Mitch,
Nice to meet you. According to your message, I'd like to know if you can
raise an example for me to reference. Thanks
Jack
"Mitch" <anonymous@.discussions.microsoft.com>
??:537a01c42cd1$c241b690$a301280a@.phx.gbl...[vbcol=seagreen]
> Since the SQL server doesn't have visibility to internal
> C++ variables in an application, the variables need to be
> passed to the server somehow. There are a variety of ways
> of doing this including converting the value to text and
> stuffing it in the query string. A better way is to use
> the API's parameter passing functions (i.e. for ODBC this
> is SQLBindParameter).
> Cheers
> Mitch vH
> Microsoft Consulting
> Server/mySQL?
> variable2)
> not in the field
|||Hi,
I've just asked other guys. They said to convert integers into varchars
using sprintf then stuffing it into the SQLStr. I'm in doubt about the
necessarity of this move because the field I designed was an integer field.
Could anyone explain?
Thanks
Jack
"Jack" <jl@.knight.com> glsD
:Oim1KPNLEHA.2624@.TK2MSFTNGP09.phx.gbl...
> Hi Mitch,
> Nice to meet you. According to your message, I'd like to know if you can
> raise an example for me to reference. Thanks
> Jack
> "Mitch" <anonymous@.discussions.microsoft.com>
> ??:537a01c42cd1$c241b690$a301280a@.phx.gbl...
>

Adding C++ var into db

Since the SQL server doesn't have visibility to internal
C++ variables in an application, the variables need to be
passed to the server somehow. There are a variety of ways
of doing this including converting the value to text and
stuffing it in the query string. A better way is to use
the API's parameter passing functions (i.e. for ODBC this
is SQLBindParameter).
Cheers
Mitch vH
Microsoft Consulting

>--Original Message--
>What is the syntax of adding C++ variables into SQL
Server/mySQL?
>Could anyone raise an example?
>I've tried
>insert into aTable (field1, field2) values (variable1,
variable2)
>But mysql throws error messages at me saying varible1 is
not in the field
>list. Haven't tried it yet for SQL Server..
>Thanks for your attention
>Jack
>
>.
>Hi Mitch,
Nice to meet you. According to your message, I'd like to know if you can
raise an example for me to reference. Thanks
Jack
"Mitch" <anonymous@.discussions.microsoft.com>
'?:537a01c42cd1$c241b690$a301280a@.phx.gbl...[vbcol=seagreen]
> Since the SQL server doesn't have visibility to internal
> C++ variables in an application, the variables need to be
> passed to the server somehow. There are a variety of ways
> of doing this including converting the value to text and
> stuffing it in the query string. A better way is to use
> the API's parameter passing functions (i.e. for ODBC this
> is SQLBindParameter).
> Cheers
> Mitch vH
> Microsoft Consulting
>
> Server/mySQL?
> variable2)
> not in the field|||Hi,
I've just asked other guys. They said to convert integers into varchars
using sprintf then stuffing it into the SQLStr. I'm in doubt about the
necessarity of this move because the field I designed was an integer field.
Could anyone explain?
Thanks
Jack
"Jack" <jl@.knight.com> glsD
:Oim1KPNLEHA.2624@.TK2MSFTNGP09.phx.gbl...
> Hi Mitch,
> Nice to meet you. According to your message, I'd like to know if you can
> raise an example for me to reference. Thanks
> Jack
> "Mitch" <anonymous@.discussions.microsoft.com>
> '?:537a01c42cd1$c241b690$a301280a@.phx.gbl...
>