Command Object problem (ADO) 
Author Message
 Command Object problem (ADO)

Hi there;

i hope some one can help mw with this;
let's say that i want to collect some data from text boxeson a form and
then i want to create a table in SQL server 7.o that is based on the
data i collected ; for an example:

let's say i have declared a globbal connection object in a .bas file
and named the object goConn;

in my Collect_Click() sub

   Dim firstField as String
   Dim secField as String
   Dim myCommand as Command
   Dim strSQL as String

  ' now I'll assign the first 2 variables with data from my text boxes

   firstField = txtFirstField.Text
   secFileld = txtSecField.Text

  ' Fire up the Command object

   Set myCommand = new Command
   Set myCommand.ActiveConnection = goConn
   myCommand.CommandType = adCmdUnknown

   ' Now what i really wanna do is create a table in sql Server, and
name the fields or olumns in it whatever i have collected from the text
boxes?!! do you know what i mean

I can't just go and say

   myCommand.CommandText = "Create Table test_Table ( firstField
char(5), secField char(6)"

because this is going to name the columns "firstField and secField" and
I want them to be named what ever those variables contain

does anybody understand what i'm talking about

hope so

please help

* Sent from RemarQ http://www.*-*-*.com/ The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!



Mon, 25 Mar 2002 03:00:00 GMT  
 Command Object problem (ADO)
You'll have to change the code to:

myCommand.CommandText = "Create Table test_Table (" & firstField & " char(5), "
& secField & " char(6))"

to make it work. To test this, put a break point on the above line and then
highlight, press shift F9 to see what it resolves out to.

Bruce

Quote:

> [snip]
>    myCommand.CommandText = "Create Table test_Table ( firstField
> char(5), secField char(6)"

> because this is going to name the columns "firstField and secField" and
> I want them to be named what ever those variables contain



Tue, 26 Mar 2002 03:00:00 GMT  
 Command Object problem (ADO)
Do it this way:

myCommand.CommandText = "Create Table test_Table ( " & firstField & " char
(5), " & secField & " char(6)"

Assume firstField = "Field_One" and secField = "Field_Two"

the above will be translated into:

myCommand.CommandText = "Create Table test_Table ( Field_One char(5),
Field_Two char(6)"

Good Luck,
Roy

Quote:

> Hi there;

> i hope some one can help mw with this;
> let's say that i want to collect some data from text boxeson a form and
> then i want to create a table in SQL server 7.o that is based on the
> data i collected ; for an example:

> let's say i have declared a globbal connection object in a .bas file
> and named the object goConn;

> in my Collect_Click() sub

>    Dim firstField as String
>    Dim secField as String
>    Dim myCommand as Command
>    Dim strSQL as String

>   ' now I'll assign the first 2 variables with data from my text boxes

>    firstField = txtFirstField.Text
>    secFileld = txtSecField.Text

>   ' Fire up the Command object

>    Set myCommand = new Command
>    Set myCommand.ActiveConnection = goConn
>    myCommand.CommandType = adCmdUnknown

>    ' Now what i really wanna do is create a table in sql Server, and
> name the fields or olumns in it whatever i have collected from the text
> boxes?!! do you know what i mean

> I can't just go and say

>    myCommand.CommandText = "Create Table test_Table ( firstField
> char(5), secField char(6)"

> because this is going to name the columns "firstField and secField" and
> I want them to be named what ever those variables contain

> does anybody understand what i'm talking about

> hope so

> please help

> * Sent from RemarQ http://www.remarq.com The Internet's Discussion
Network *
> The fastest and easiest way to search and participate in Usenet - Free!

------------------  Posted via CNET Help.com  ------------------
                      http://www.help.com/


Tue, 26 Mar 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. connection problem with ADO command object ......

2. Command Object Problem in ADO

3. Problem using the ADO Command object

4. Problem passing ADO command objects as parameters in MTS

5. Problem passing ADO command objects as parameters in MTS

6. ADO Command object and MSShape commands

7. Using the ADO Command Object to send an Execute command

8. ADO Command Object using Multiple Connection Objects

9. Setting the recordset for a form with an ADO command object

10. Setting the ActiveConnection property of a Command Object (ADO 2.7)

11. Passing variables to an ADO Command or RecordSet Object in another frame

12. Parameterized SQL statements with ADO.Command object

 

 
Powered by phpBB® Forum Software