Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx thread: Please help me. I want to assign value for ADOParameter


Message #1 by "Quynh D. Nguyen" <quynhnguyen@b...> on Thu, 15 Feb 2001 12:37:41
Hi all,

 

Please help me, I was used the SQLCommand and SQLParameter for insert data into database.

And I was used some parameters in the SQLCommand object. That work is fine.

 

But now, I rewrite it by ADOCommand and ADOParameter. But the compile always shows me the error when I assigned value for any
parameter in the collection of ADOCommand.

 

My code is these (language: C#):

===================================================

ADOConnection cnnTimesheet = new ADOConnection(strConnectionString);

ADOCommand cmdTimesheet = new ADOCommand();



string strSQL = "Insert Into tmsTasks(UserID, CreateDate, Task, Status, Start, Stop, Duration, Interrupt, Description) ";



strSQL += "Values(@UserID, @CreateDate, @Task, 'New', null, null, 0, 0, @Description)";



cmdTimesheet.ActiveConnection = cnnTimesheet;



cmdTimesheet.CommandText = strSQL;



cmdTimesheet.ActiveConnection.Open();



cmdTimesheet.Parameters.Add("@UserID", ADODBType.Char, 30, "UserID");



cmdTimesheet.Parameters("@UserID").Value = "SecondUser";



==================================================



The Microsoft .NET compile always shows me: 'System.Data.ADO.ADOCommand.Parameters' denotes a 'property' where a 'method' was
expected (at red word in my code above)



Please help me for know that.



Thanks for your attention.





Quynh Nguyen



Message #2 by =?iso-8859-1?Q?Fredrik_Norm=E9n?= <fredrik.normen@e...> on Thu, 15 Feb 2001 14:09:31 +0100
Try this:



ADOParameter myParam = null;



myParam = cmdTimesheet.Parameters.Add(new ADOParameter("@UserID",

ADODBType.Char, 30, "UserID"));

myParam.Direction = ParameterDirection.Input;



...



cmdTimesheet.Parameters["@UserID"].Value = "SeconUser";

...



/Fredrik Normén





-----Original Message-----

From: Quynh D. Nguyen [mailto:quynhnguyen@b...]

Sent: den 15 februari 2001 12:38

To: ASP+

Subject: [aspx] Please help me. I want to assign value for ADOParameter





Hi all,



Please help me, I was used the SQLCommand and SQLParameter for insert data

into database.

And I was used some parameters in the SQLCommand object. That work is fine.



But now, I rewrite it by ADOCommand and ADOParameter. But the compile always

shows me the error when I assigned value for any parameter in the collection

of ADOCommand.



My code is these (language: C#):

===================================================

ADOConnection cnnTimesheet = new ADOConnection(strConnectionString);

ADOCommand cmdTimesheet = new ADOCommand();



string strSQL = "Insert Into tmsTasks(UserID, CreateDate, Task, Status,

Start, Stop, Duration, Interrupt, Description) ";



strSQL += "Values(@UserID, @CreateDate, @Task, 'New', null, null, 0, 0,

@Description)";



cmdTimesheet.ActiveConnection = cnnTimesheet;



cmdTimesheet.CommandText = strSQL;



cmdTimesheet.ActiveConnection.Open();



cmdTimesheet.Parameters.Add("@UserID", ADODBType.Char, 30, "UserID");



cmdTimesheet.Parameters("@UserID").Value = "SecondUser";



==================================================



The Microsoft .NET compile always shows me:

'System.Data.ADO.ADOCommand.Parameters' denotes a 'property' where a

'method' was expected (at red word in my code above)



Please help me for know that.



Thanks for your attention.





Quynh Nguyen



Message #3 by Scott Guthrie <scottgu@m...> on Thu, 15 Feb 2001 15:56:31 -0800
Hi Quynh,



I have a ADO.NET Code Builder (for both the SQL Provider and ADO Provider)

that you can use at: http://www.eraserver.net/scottgu



It allows you to type in a paramerized SQL query (you also need to supply

datatype information), and then it will generate all of the ADO.NET code you

need to use to invoke it.



Hope this helps,



Scott



-----Original Message-----

From: Quynh D. Nguyen [mailto:quynhnguyen@b...]

Sent: Thursday, February 15, 2001 4:38 AM

To: ASP+

Subject: [aspx] Please help me. I want to assign value for ADOParameter





Hi all,

 

Please help me, I was used the SQLCommand and SQLParameter for insert data

into database.

And I was used some parameters in the SQLCommand object. That work is fine.

 

But now, I rewrite it by ADOCommand and ADOParameter. But the compile always

shows me the error when I assigned value for any parameter in the collection

of ADOCommand.

 

My code is these (language: C#):

===================================================

ADOConnection cnnTimesheet = new ADOConnection(strConnectionString);

ADOCommand cmdTimesheet = new ADOCommand();



string strSQL = "Insert Into tmsTasks(UserID, CreateDate, Task, Status,

Start, Stop, Duration, Interrupt, Description) ";



strSQL += "Values(@UserID, @CreateDate, @Task, 'New', null, null, 0, 0,

@Description)";



cmdTimesheet.ActiveConnection = cnnTimesheet;



cmdTimesheet.CommandText = strSQL;



cmdTimesheet.ActiveConnection.Open();



cmdTimesheet.Parameters.Add("@UserID", ADODBType.Char, 30, "UserID");



cmdTimesheet.Parameters("@UserID").Value = "SecondUser";



==================================================



The Microsoft .NET compile always shows me:

'System.Data.ADO.ADOCommand.Parameters' denotes a 'property' where a

'method' was expected (at red word in my code above)



Please help me for know that.



Thanks for your attention.





Quynh Nguyen





---

http://www.asptoday.com - the leading site for timely,

in-depth information for ASP developers everywhere.






Message #4 by "Steve Schofield" <steve@a...> on Thu, 15 Feb 2001 22:31:49 -0500
http://www.aspfree.com/allzips/databuilder.zip  has the Databuilder

available for download.



* -----------------------------------------*

* Steve Schofield

* steve@a...

*

* Webmaster

* http://www.aspfree.com

* http://www.abc2xml.com

* http://www.thinclientzone.com

* -----------------------------------------*



----- Original Message -----

From: "Scott Guthrie" <scottgu@m...>

To: "ASP+" <aspx@p...>

Sent: Thursday, February 15, 2001 6:56 PM

Subject: [aspx] RE: Please help me. I want to assign value for ADOParamete r





> Hi Quynh,

>

> I have a ADO.NET Code Builder (for both the SQL Provider and ADO Provider)

> that you can use at: http://www.eraserver.net/scottgu

>

> It allows you to type in a paramerized SQL query (you also need to supply

> datatype information), and then it will generate all of the ADO.NET code

you

> need to use to invoke it.

>

> Hope this helps,

>

> Scott

>

> -----Original Message-----

> From: Quynh D. Nguyen [mailto:quynhnguyen@b...]

> Sent: Thursday, February 15, 2001 4:38 AM

> To: ASP+

> Subject: [aspx] Please help me. I want to assign value for ADOParameter

>

>

> Hi all,

>

> Please help me, I was used the SQLCommand and SQLParameter for insert data

> into database.

> And I was used some parameters in the SQLCommand object. That work is

fine.

>

> But now, I rewrite it by ADOCommand and ADOParameter. But the compile

always

> shows me the error when I assigned value for any parameter in the

collection

> of ADOCommand.

>

> My code is these (language: C#):

> ===================================================

> ADOConnection cnnTimesheet = new ADOConnection(strConnectionString);

> ADOCommand cmdTimesheet = new ADOCommand();

>

> string strSQL = "Insert Into tmsTasks(UserID, CreateDate, Task, Status,

> Start, Stop, Duration, Interrupt, Description) ";

>

> strSQL += "Values(@UserID, @CreateDate, @Task, 'New', null, null, 0, 0,

> @Description)";

>

> cmdTimesheet.ActiveConnection = cnnTimesheet;

>

> cmdTimesheet.CommandText = strSQL;

>

> cmdTimesheet.ActiveConnection.Open();

>

> cmdTimesheet.Parameters.Add("@UserID", ADODBType.Char, 30, "UserID");

>

> cmdTimesheet.Parameters("@UserID").Value = "SecondUser";

>

> ==================================================

>

> The Microsoft .NET compile always shows me:

> 'System.Data.ADO.ADOCommand.Parameters' denotes a 'property' where a

> 'method' was expected (at red word in my code above)

>

> Please help me for know that.

>

> Thanks for your attention.

>

>

> Quynh Nguyen

>

>

>


  Return to Index