7 Replies - 2246 Views - Last Post: 13 October 2010 - 01:06 PM Rate Topic: -----

#1 Kind Redemeer  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 8
  • Joined: 13-October 10

What is the c # code similar to code vb (If RS.EOF Then)

Posted 13 October 2010 - 12:33 AM

Good day everyone!,
What is the c # code similar to vb code (If RS.EOF Then)... thanks
Is This A Good Question/Topic? 0
  • +

Replies To: What is the c # code similar to code vb (If RS.EOF Then)

#2 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5442
  • View blog
  • Posts: 11,676
  • Joined: 02-June 10

Re: What is the c # code similar to code vb (If RS.EOF Then)

Posted 13 October 2010 - 12:42 AM

if (RS.EOF)
{
   // Then do this
}
else
{
   // Do this instead
}



May I suggest picking up a basic C# introductory book? It's not that people here don't want to be helpful, but there is a certain amount of basic learning work that one should really take upon themselves before asking for help. There are so many great "How do I build my first application" tutorials on the web... There are dozens of "Learn C# in 21 days", "My first C# program" books at your look book seller or even public library... Asking a forum, any forum, to hand-hold you through it is just redundant. In many ways it disrespects the people who have invested dozens of hours in the on-line tutorials and those that spent thousands of hours in authoring books.
Was This Post Helpful? 0
  • +
  • -

#3 Kind Redemeer  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 8
  • Joined: 13-October 10

Re: What is the c # code similar to code vb (If RS.EOF Then)

Posted 13 October 2010 - 01:05 AM

thanks for reply ,
but what about this error (RS does not exist in the current context)
.............. thank you
Was This Post Helpful? 0
  • +
  • -

#4 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5442
  • View blog
  • Posts: 11,676
  • Joined: 02-June 10

Re: What is the c # code similar to code vb (If RS.EOF Then)

Posted 13 October 2010 - 01:36 AM

View PostKind Redemeer, on 13 October 2010 - 12:05 AM, said:

thanks for reply ,
but what about this error (RS does not exist in the current context)
.............. thank you



You have not made an object named RS, within the current scope. There is no 'RS' object that is defined/alive at the time this line is executed.
Was This Post Helpful? 0
  • +
  • -

#5 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5442
  • View blog
  • Posts: 11,676
  • Joined: 02-June 10

Re: What is the c # code similar to code vb (If RS.EOF Then)

Posted 13 October 2010 - 01:48 AM

Based on the last few threads that you have started, one right after the other...

Let me first say "Welcome to DIC". Its always good to have new coders find and join the board.

Second let me say that you need to take a little responsibility for getting a basic intro to C# book, doing some of the thousands of on-line tutorials etc. Can you imagine what the forum would look like if 400,000 new users started posting dozens of questions like "what is an if statement", "what is a 'case' construct" and so on for the 100,000 keywords that are in the C# language? You really can't expect to come onto the forum and have people write custom tutorials for you for every single word in the C# language.


I agree we are happy to help. Sometimes the best help is examples. Sometimes its solving the problem. Sometimes its pointing toward some good resources.

I am going to guess that you are trying to teach yourself C# without much guidance, a decent book or without knowing where to look. Sometimes just knowing where to look can make all the difference. Google is your friend.
Search with either "C#" or "MSDN" as the first word:
"C# picturebox load image openfiledialog" Its all the key parts of your question
Any new control like a picturebox is fully explained on the MSDN with example code so this works: "MSDN Picturebox"

But honestly, just typing away and seeing what pops up in Intellisense is going to make your self-education take 20 years. You can learn by trying to reverse engineer the language through banging on the keyboard - or you can learn by doing the tutorials and following a good "How to learn C#" book.

May I suggest picking up a basic C# introductory book? It's not that people here don't want to be helpful, but there is a certain amount of basic learning work that one should

really take upon themselves before asking for help. There are so many great "How do I build my first application" tutorials on the web... There are dozens of "Learn C# in 21 days", "My first C# program" books at your look book seller or even public library... Asking a forum, any forum, to hand-hold you through it is just redundant. In many ways it disrespects the people who have invested dozens of hours in the on-line tutorials and those that spent thousands of hours in authoring books.

Build a Program Now! in Visual C# by Microsoft Press, ISBN 0-7356-2542-5 is a terrific book that has you build a Windows Forms application, a WPF app, a database application, your own web browser.

C# Cookbooks
Are a great place to get good code, broken down by need, written by coding professionals. You can use the code as-is, but take the time to actually study it. These professionals write in a certain style for a reason developed by years of experience and heartache.

Microsoft Visual Studio Tip, 251 ways to improve

your productivity
, Microsoft press, ISBN 0-7356-2640-5
Has many, many great, real-world tips that I use all the time.

The tutorials below walk through making an application including inheritance, custom events and custom controls.
Quick and easy custom events
Bulding an application - Part 1
Building an application - Part 2
Working with environmental variables

Writing a text file is always one of the first things people want to do, in order to store data like high-scores, preferences and so on
Writing a text file tutorial.

These are just good every-day references to put in your bookmarks.
MSDN C# Developers Center with tutorials
Welcome to Visual Studio

Have you seen the MSDN Code Samples? They spent a lot of time creating samples and demos. It seems a shame to not use

them.

  • Anonymous Delegates: Demonstrates the use of unnamed delegates to reduce application complexity.
  • Arrays: Shows how to use arrays.
  • Attributes: Shows how to create custom attribute classes, use them in code, and query them through reflection.
  • Collection Classes: Shows how to make non-generic collection classes that can be used with the foreach statement.
  • COM Interop Part I: Shows how to use C# to interoperate with COM objects.
  • COM Interop Part II: Shows how to a use a C# server together with a C++ COM client.
  • Commandline: Demonstrates simple command-line processing and array indexing.
  • Condiational Methods: Demonstrates conditional methods, which provide a powerful mechanism by which calls to methods can be included or omitted depending on whether a symbol

    is defined.
  • Delegates: Shows how delegates are declared, mapped to static and instance methods, and combined into multicast delegates.
  • Events: Shows how to declare, invoke, and configure events in C#.
  • Explicit Interface: Demonstrates how to explicitly implement interface members and how to access those members from interface instances.
  • Generics: Shows how to make generic collection classes that can be used with the foreach statement.
  • Hello World: A Hello World application.
  • Indexers Part I: Shows how C# classes can declare indexers to provide array-like access to objects.
  • Indexers Part II: Shows how to implement a class that uses indexed properties. Indexed properties enable you to use a class that represents an array-like collection.
  • Libraries: Shows how to use compiler options to create a DLL from multiple source files; also, how to use the library in other programs
  • Named and Optional (C# 4.0): Demonstrates Named and Optional parameters, an alternative to method overloads
  • Nullable: Demonstrates value types, such as double and bool, that can be set to null
  • Office Sample (C# 4.0): Demonstrates how Dynamic and COM Interop make it easy to call Microsoft Office in C# 4.0
  • OLEDB: Demonstrates how to use a Microsoft Access database from C# by creating a dataset and adding tables to it.
  • Operator Overloading: Shows how user-defined classes can overload operators
  • Partial Types: Demonstrates how classes and structures can be defined in multiple C# source-code files
  • PInvoke: Shows how to call exported DLL functions from C#
  • Properties: Shows how properties are declared and used; also demonstrates abstract properties
  • Python Sample (C# 4.0): Learn how to call a Python script by using the Dynamic feature in C# 4.0
  • Security: Discusses .NET Framework security and shows how to modify security permissions in C# by using permission classes and permission attributes
  • Simple Variance (C# 4.0): See how Covariance and Contravariance are supported in generic interfaces and delegates
  • Structs: Shows how to use structs in C#.
  • Threading: Demonstrates various thread activities such as creating and executing a thread, synchronizing threads, interacting between threads, and using a thread pool
  • Unsafe: Shows how to use unmanaged code (code that uses pointers) in C#
  • User Conversions: Shows how to define conversions to and from user-defined types
  • Versioning: Demonstrates versioning in C# by using the override and new keywords
  • XML Documents: Shows how to document code by using XML
  • Yield: Demonstrates how to use the yield keyword to filter items in a collection

This post has been edited by tlhIn'toq: 13 October 2010 - 01:51 AM

Was This Post Helpful? 0
  • +
  • -

#6 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1524
  • View blog
  • Posts: 5,957
  • Joined: 21-March 08

Re: What is the c # code similar to code vb (If RS.EOF Then)

Posted 13 October 2010 - 04:50 AM

If you have the VB.Net code and want it converted to C#, I suggest using this converter. It actually does very well.

http://converter.telerik.com/

Other than that, your question is very vague. Without seeing the code that you have, it's hard for us to help you anymore than what tlhIn'toq already has.
Was This Post Helpful? 0
  • +
  • -

#7 Kind Redemeer  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 8
  • Joined: 13-October 10

Re: What is the c # code similar to code vb (If RS.EOF Then)

Posted 13 October 2010 - 11:26 AM

code is vb code that i went convert to c#
(Access database)
If Text1 = "" Or Text2 = "" Then
    MsgBox " Sorry, please enter your username and password  ", vbCritical + vbMsgBoxRight, " error "
    Exit Sub
 End If
 
 SQLs = "Select * From User Where UserName = ' " & Text1 & " '  And Password = ' " & Text2 & " ' "
   
   

 
 If RS.EOF Then
    MsgBox " Sorry, your password or user name wrong! ", vbCritical + vbMsgBoxRight, " Error Login "
Else
'save this information
        UserNames = Text1
        UserPassword = Text2

'login main
Set RS = Nothing
        Set DB = Nothing
        MDIForm1.Show
        Unload Me
      End If
      
End Sub  

This post has been edited by Kind Redemeer: 13 October 2010 - 11:33 AM

Was This Post Helpful? -1
  • +
  • -

#8 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1524
  • View blog
  • Posts: 5,957
  • Joined: 21-March 08

Re: What is the c # code similar to code vb (If RS.EOF Then)

Posted 13 October 2010 - 01:06 PM

How about this....forget about how you do it in VB6(or earlier) and update that to use a more current way of user validation.

Look into using the OdbcConnection, OdbcCommand, and OdbcDataReader classes to query an Access database.

Trust me. You do not want to rehash VB6 code into .Net. There are MUCH better ways of doing things in .Net. Learn them, use them. Forget about how VB6 handled database operations.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1