Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   C# (http://www.programmingforums.org/forum16.html)
-   -   System.Data (http://www.programmingforums.org/showthread.php?t=12413)

King Jan 20th, 2007 11:11 PM

System.Data
 
In Visual Studio 2003 I could run the following statement:
:

cmdUser.Parameters.Add("@firstname", SqlDbType.VarChar, 25).Direction = ParameterDirection.Output;
But now in VS2005 it won't compile because it doesn't know what SqlDbType and ParameterDirection are. If I add the System.Data. in front of SqlDbType and ParameterDirection it will work fine. Is VS2005 supposed to behaving like this, or am I missing something?

Thanks.

Samuaijack Jan 20th, 2007 11:47 PM

i didn't play with VS 2005 but i think what you should do is to write (using System.Data.SqlClient).

King Jan 20th, 2007 11:58 PM

I have done that...

xavier Jan 21st, 2007 1:18 AM

I have these 2 inclusions

using System.Data;
using System.Data.SqlClient;

and this:

:

cmd.Parameters.Add("@asd",SqlDbType.VarChar,25).Direction = ParameterDirection.Output;

compiles fine.

PhilBon Jan 21st, 2007 2:10 AM

Maybe I can Give you some background info. What I have found is that you have to be more explicit about what Libraries you want the compiler to use. Cause I to had this kind of problem. Best thing to figure out what you need is put in what you think:
:

cmdUser.Parameters.Add("@firstname", SqlDbType.VarChar, 25).Direction = ParameterDirection.Output;
and then mouse over it or right click (I can't remember) and it should say "Change To:..." and in front of the cmdUser should be the library that you need. So this would be System.Data if that is what it's part of (I didn't run it to check). If you are only going to use the Library once I think you should leave it to System.Data.cmdUser because then it might lessen the compile time. One thing to know, I did this in Visual Basic .Net 2005 so I'm not 100% sure if it will work with C# but I'm pretty sure because it's the same IDE.

King Jan 21st, 2007 3:56 AM

OK I fixed it. I just closed down my project and re-opened it and it compiled fine... very weird.

Thanks for the input guys.

Arevos Jan 21st, 2007 6:44 AM

Quote:

Originally Posted by King (Post 122904)
OK I fixed it. I just closed down my project and re-opened it and it compiled fine... very weird.

Yeah, Visual Studio 2003 has these little moments as well, and SQL Server 2005 very occassionally also manages to screw itself up. Just remember you're dealing with Microsoft products, which whilst feature-packed, might not be always consistent and stable.

milot Jan 21st, 2007 11:25 AM

Did you tried adding System.Data.Common in using directives and try
:

  1. cmdUser.Parameters.AddWithValue()



All times are GMT -5. The time now is 1:42 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC