|
Hello
[WebMethod Description="Returns true if User ID in Database")]
public bool isUserIdValid( int nUserID )
{
DataSet myData = new DataSet();
sqlDataAdapter1.SelectCommand.Parameters["@userID"].Value = nUserID;
sqlDataAdapter1.Fill( myData, "UserID");
myData.Tables[????
return true;
}
Lets say we have a web method such as the one above, it calls a stored procedure on an sql database and returns an int, 0 if user id invalid, or the value of the user id if valid.
So, Ive passed the @userid to the sqlDataAdapter and filled a dataset ie myData with the results.
How do I now get at the data in the DataSet myData ive just created?????
Please help with code required to get the value returned by the stored procedure
Regards
Li Mu Bai
Wudan Master (Deceased)
|
|
|
|
|
Li Mu Bai wrote:
How do I now get at the data in the DataSet myData ive just created?????
Have you tried to access the data like so:
myData.Tables["UserID"]
So your code could possibly look something like:
[WebMethod Description="Returns true if User ID in Database")]
public bool isUserIdValid( int nUserID )
{
DataSet myData = new DataSet();
sqlDataAdapter1.SelectCommand.Parameters["@userID"].Value = nUserID;
if ( sqlDataAdapter1.Fill( myData, "UserID") > 0 )
{
if ( myData.Tables["UserID"] != 0 )
{
return true;
}
}
<br><br>
return false;
}
Roger Stewart
"I Owe, I Owe, it's off to work I go..."
|
|
|
|
|
Hi guys,
I just want to read a field in a column in a dataset.
I dont want to fill a grid, i just want to check one filed for a value???
Regards
|
|
|
|
|
And your question is what?
I'm going to assume it is how you read a field in a dataset.
First, get the proper DataTable out of the Tables property of the DataSet; then find the appropriate Row in the Rows property of the DataTable, finally read the appropriate column out of that.
James
"Java is free - and worth every penny." - Christian Graus
|
|
|
|
|
If you don't have Visual C# (ie you purchased VB.NET standard) then you're out of luck with this tool since it was created with C#. It is also a tool created for use with VS.NET, so you are also out of luck if you aren't using VS.NET.
When I did a reinstall of CollectionGen a few minutes ago I took a look at the readme file and found that it was missing a few steps.
First off download it from the link above, then unzip it to the directory of your choice (this will be the final resting place for it so place it where you want it).
Now open the CollectionGen solution file (CollectionGen.sln) you will probably get some errors about not being able to find the Visual Source Safe server; just tell it ok to get through the warnings.
Now if you don't don't have VB.NET, remove the vbtestcli project from the solution [right click on it and choose remove, tell it to overwrite the solution file if it complains about being read-only].
This is where the readme is missing some steps.
Right click on the CollectionGen project, and choose "Add Reference..." click the Browse button and browse to the Microsoft Visual Studio .NET\Common7\IDE directory select the "Microsoft.VSDesigner.dll" file. 'Ok' back to the main IDE. Now right click on the testcli project and choose "Add Reference...", click Browse, and browse back to that directory again. Select the "Microsoft.VSDesigner.dll" file, then click Browse again; this time selecing the "microsoft.visualstudio.designer.interfaces.dll" file. Again, click OK back to the main IDE.
Now that that is done, change the combobox at the top of the IDE to say Release instead of Debug and build the solution.
Using the Command Prompt provided by VS.NET (look in VS.NET's Tools program group in the start menu) run the setup.bat file located in the CollectionGen\redist.
That should be all you have to do
To test it right click on one of the XML files in the testcli project and choose "Run Custom Tool". If all goes well you'll see VS.NET work for a bit then nothing will happen. That is good!
Now to use it in your own program simply create an XML file of the same format as listed in the readme file. Add that file to your project, then change the "Custom Tool" property to "SBCollectionGenerator".
Thats it
James
"Java is free - and worth every penny." - Christian Graus
|
|
|
|
|
|
Nishant S wrote:
what is this collectiongen thingie
Strongly typed collection generator for VS.NET.
Essentially you have an XML file that specifies the types and what kind of collection to generate and it does so. If you want to support a new type of collection its as simple as creating a new XSLT file and adding it to the project and recompiling CollectionGen.
James
"Java is free - and worth every penny." - Christian Graus
|
|
|
|
|
Does anyone know how to generate an enum of the video capture hardware, or how you would get other kind of information about hardware installed on a computer in C#?
Thanks,
Steven
|
|
|
|
|
How can I create a statusbar with 3 panels with 3 sliders (in every panel 1 slider)?
Just like this:
Text... |---[Slider]---| |---[Slider]---| |---[Slider]---|
|
|
|
|
|
You should probably just make your own control, and make it look like a statusbar. When you add it to your form, just dock it to the bottom.
|
|
|
|
|
I mean, who decided that I could not do this ?
const int n = x+5;
And why can't I create a static method and use it from a class instance OR overload a method so that both the static and non-static versions exist ?
Who wrote this rubbish ?
Christian
come on all you MS suckups, defend your sugar-daddy now. - Chris Losinger - 11/07/2002
|
|
|
|
|
Christian Graus wrote:
const int n = x+5;
I don't see any problem here.
Step back, rub your eyes, take a deep breath, stretch a bit, and reflect on the relative importance of CP, CG, the age / travel time sustained by supposedly 'fresh' cheese curds, and Life in General. - Shog9
|
|
|
|
|
Nor do I, but the compiler will only accept
const int n = 5;
Christian
come on all you MS suckups, defend your sugar-daddy now. - Chris Losinger - 11/07/2002
|
|
|
|
|
I meant to say that I don't see any problems with compiler not accepting it. You need to get over C+ mentality. there ain't no const variables only const constants.
Step back, rub your eyes, take a deep breath, stretch a bit, and reflect on the relative importance of CP, CG, the age / travel time sustained by supposedly 'fresh' cheese curds, and Life in General. - Shog9
|
|
|
|
|
Rama Krishna wrote:
I meant to say that I don't see any problems with compiler not accepting it.
Thats cool. So why does my compiler not accept it ?
Rama Krishna wrote:
need to get over C+ mentality. there ain't no const variables only const constants.
That's really deep, but I have no idea what the hell it means. :P
Christian
come on all you MS suckups, defend your sugar-daddy now. - Chris Losinger - 11/07/2002
|
|
|
|
|
A const in C# and the .NET framework is just that. A constant. When you create a constant in .NET it is not stored as a variable. Anywhere that it is used the value is copied directly into your code. So it makes sense that they will not allow you to use a variable in teh declaration of a constant.
Jared
jparsons@jparsons.org
www.prism.gatech.edu/~gte477n
|
|
|
|
|
I'm not interested in the under the hood semantics ( I was actually reading up on them in the Richter book this morning ), I just want to know how to pass a variable into a function and then from that variable define another that is const for the life of the function call. const is an incredibly important part of programming in C++ because it allows me to specify that I want to be able to trust that a value has not changed. Does C# provide another mechanism for this in regard to function parameters, etc. ?
Christian
come on all you MS suckups, defend your sugar-daddy now. - Chris Losinger - 11/07/2002
|
|
|
|
|
Christian Graus wrote:
That's really deep,
I was watching a movie when I wrote that.
Anyway,
const in C# is not same as const in C++.
These are valid bothe C# and C++
const int x = 200;
const int y = 200 + x;
But this is not
void func()
{
int x;
const int y = x + 10;
}
For the simple reason that compiler cannot calculate the value of y at compile time.
Step back, rub your eyes, take a deep breath, stretch a bit, and reflect on the relative importance of CP, CG, the age / travel time sustained by supposedly 'fresh' cheese curds, and Life in General. - Shog9
|
|
|
|
|
OK then, how do I do what I want ? If the answer is I cannot then C# just plain sucks as far as this is concerned. I should be able to define a value from a variable passed into a function and mark it so that no code further down can modify the value.
Christian
come on all you MS suckups, defend your sugar-daddy now. - Chris Losinger - 11/07/2002
|
|
|
|
|
Rama Krishna wrote:
I meant to say that I don't see any problems with compiler not accepting it.
I'm sorry to inform you that my compiler still does not accept the assignment of a variable to a new, const value.
Rama Krishna wrote:
You need to get over C+ mentality. there ain't no const variables only const constants.
I still have no idea what this means. Could you please help me out here ? Are you saying I am doing it wrong, or just being cute about my use of the term 'const variable' ?
Christian
come on all you MS suckups, defend your sugar-daddy now. - Chris Losinger - 11/07/2002
|
|
|
|
|
|
Nishant S wrote:
I thought you could in C#
Nope.
class Myclass
{
static public string Myfunction()
{
return "C# can be pretty dumb at times";
}
}
Myclass s;
System.MessageBox.Show(s.Myfunction()); // No way, no how.
This will NOT work. Nor can I do this:
class Myclass
{
static public string Myfunction()
{
return "C# can be pretty dumb at times";
}
public string Myfunction()
{
return "C# can be pretty dumb at times";
}
}
as it will (correctly IMO) not compile. So if I want to provide some methods as static because they do not need any internal state access, and could be more useful if they could be accessed that way, my users cannot access them from an instance of my class.
That SUCKS.
Christian
Christian
come on all you MS suckups, defend your sugar-daddy now. - Chris Losinger - 11/07/2002
|
|
|
|
|
statics belong to the Type, not the Instance.
therefore, static methods use the Type instead of the Instance for their context.
Why do you see this as a problem?
|
|
|
|
|
Because it's counter intuitive. I've given Nish a more detailed response, if you're interested.
Christian
come on all you MS suckups, defend your sugar-daddy now. - Chris Losinger - 11/07/2002
|
|
|
|
|
Christian Graus wrote:
System.MessageBox.Show(s.Myfunction()); // No way, no how.
That's wrong usage anyway. The static method is a class method and not an instance method
Instead of s.MyFunction you *must* use MyClass.Myfunction and I think that is the right way of doing it
Nish
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
Review by Shog9
Click here for review[NW]
|
|
|
|