473,398 Members | 2,125 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

What is this c# snip in vb

geo039
47
Can anyone convert this vb.net. I don't need all the sql commands. Just the first line and declarations.

Expand|Select|Wrap|Line Numbers
  1. public List<User> GetAllUsers()
  2.     {
  3.         List<User> userList = new List<User>();  
  4.         SqlConnection myConnection = new SqlConnection(ConnectionString);
  5.         SqlCommand myCommand = new SqlCommand(SP_GET_ALL_USERS, myConnection); 
  6.  
  7.         myConnection.Open();
  8.         SqlDataReader reader = myCommand.ExecuteReader();
  9.  
  10.         while (reader.Read())
  11.         {
  12.             User user = new User((int)reader["UserID"],(string) reader["FirstName"],(string) reader["LastName"]);
  13.             userList.Add(user); 
  14.         }        myConnection.Close();
  15.         reader.Close(); 
  16.         myCommand.Dispose();
  17.  
  18.         if (userList != null && userList.Count > 0)
  19.             return userList;
  20.         else return null; 
  21.  
  22.     }
Aug 22 '07 #1
2 1347
Plater
7,872 Expert 4TB
Try something like this?
Expand|Select|Wrap|Line Numbers
  1. Public Function GetAllUsers() As List<User>
  2. {
  3.    Dim userList As List<User> = new List<User>
  4.    'other stuff
  5.    return userList
  6. }
  7.  
Aug 22 '07 #2
Public Function GetAllUsers() As List(Of User)


Dim userList As New List(Of User)()
Dim myConnection As New SqlConnection(ConnectionString)
Dim myCommand As New SqlCommand(SP_GET_ALL_USERS, myConnection)

myConnection.Open()
Dim reader As SqlDataReader = myCommand.ExecuteReader()

While reader.Read()
Dim user As New User(CInt(reader("UserID")), DirectCast(reader("FirstName"), String), DirectCast(reader("LastName"), String))
userList.Add(user)
End While
myConnection.Close()
reader.Close()
myCommand.Dispose()

If userList IsNot Nothing AndAlso userList.Count > 0 Then
Return userList
Else
Return Nothing
End If

End Function
================================================== ====
Use this site for converting codes from C# to VB and vice-versa

http://labs.developerfusion.co.uk/co...arp-to-vb.aspx
Aug 23 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

47
by: Neal | last post by:
Patrick Griffiths weighs in on the CSS vs table layout debate in his blog entry "Tables my ass" - http://www.htmldog.com/ptg/archives/000049.php . A quite good article.
86
by: Michael Kalina | last post by:
Because when I asked for comments on my site-design (Remember? My site, your opinion!) some of you told me never to change anything on font-sizes! What do you guys think of that:...
5
by: John Gabriele | last post by:
I'm hoping someone can please help me remember the C++ rule: When you're writing a header file for a class (say, some_namespace::Bar), and that class makes use of another class...
15
by: Walter Dnes (delete the 'z' to get my real address | last post by:
I'm trying to initialize an array of error messages, so that I can print out an error message by using the 'nth string in an array, e.g. printf("%s\n", messages); I'm still hazy on arrays of...
22
by: vietor.liu | last post by:
is this? int hashpjw(char* str,int size) { unsigned long h=0,g; for(unsigned char *p=(unsigned char*)str;*p;++p) { h=(h<<4)+*p; if(g=(h&0xf0000000)) {
133
by: Alan Silver | last post by:
Hello, Just wondered what range of browsers, versions and OSs people are using to test pages. Also, since I don't have access to a Mac, will I have problems not being able to test on any Mac...
5
by: Christian Blackburn | last post by:
Hi Gang, I would like to use a caesar cipher on the mailto: links in my website to prevent crawlers from farming the e-mails off my site. Can someone tell me the equivalents to Chr() and Asc()...
6
by: plemon | last post by:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta...
27
by: Steven D'Aprano | last post by:
I thought that an iterator was any object that follows the iterator protocol, that is, it has a next() method and an __iter__() method. But I'm having problems writing a class that acts as an...
38
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - What books cover EcmaScript? ----------------------------------------------------------------------- Most CLJ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.