Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6185827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T01:46:58+00:00 2026-05-24T01:46:58+00:00

I already have this coded out (more or less) in Java for Linux OS,

  • 0

I already have this coded out (more or less) in Java for Linux OS, however I am not familiar enough with the syntax of .net to translate my Java code into VB2010 code… So I was hoping someone here could help me out with this.

The issue:

I am trying (as the title says) to create folders on my windows box based on the entries in our customer database (we have a lot, so i’m not about to do them by hand lol).

I want to use VB.net to create a program that will loop a query through the SQL database, take the customerIDs of our clients, and create folders for each of those names in a specific directory.

My Java code that I need to translate:

//Initializers
Statement stmt;
ResultSet rs;

rs = stmt.executeQuery("SELECT CustomerID FROM customerlist;");

System.out.println("Creating customer user database:\n");

while(rs.next()){
    String str1 = rs.getString("CustomerID");
        try {
            // Create user & Home Directory
                Process p = Runtime.getRuntime().exec("sudo useradd " + str1  + " --shell /bin/sh -m " );
                BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));

            System.out.println("Created user: \t" + str1);

            String line = null;
            while ((line = in.readLine()) != null) {
                System.out.println(line);
            }
            Thread.sleep(100);
        } catch (IOException e) {
            e.printStackTrace();
        }

}

I need the vb code to do the same thing, but only create the folder, and for the windows OS.

Important notes:

  • I am using Imports MySql.Data.MySqlClient to make the db connection.
  • it is a REMOTE mysql server, not a local one (don’t know if this note was needed).
  • We have close to 6,000 clients… (thus why i’m NOT doing it by hand!)
  • The boss says to switch from Java to VB, so no arguing the point of sticking to Java please..

Seeing as how people are thinking that i’m asking for a handout for the entire program… here is what I have so far:

Private Sub ButtonLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonLogin.Click
    conn = New MySqlConnection()
    conn.ConnectionString = "server=xxx" & ";" & "user id=xxx" & ";" & "password=xxx" & ";" & "database=companysqldb"
    Try
        conn.Open()
        MessageBox.Show("Connection Opened Successfully")

        'while loop pseudo
        '------------------
        'set query string to "SELECT CustomerID FROM customerlist;"
        'while looping through query
            'set stringvar to current loop's CustomerID

            'Create directory
            If(Not System.IO.Directory.Exists("c:\pub\users\" & stringvar)) Then System.IO.Directory.CreateDirectory("c:\pub\users\" & stringvar)
            RichTextBox.AppendText(vbCrLf & "Added folder: " & stringvar)
            RichTextBox.ScrollToCaret()

        'end while loop

    Catch myerror As MySqlException
        MessageBox.Show("Error Connecting to Database: " & myerror.Message)
    End Try

End Sub

As you can see, I have most of it already written out, however my primary difficulty is the syntax of the while loop and the SQL Query.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T01:46:59+00:00Added an answer on May 24, 2026 at 1:46 am

    SOLUTION:

    Well, after several hours of scouring the net, I finally managed to find the solution I was looking for.

    changed:

        conn.Open()
        MessageBox.Show("Connection Opened Successfully")
    
        'while loop pseudo
        '------------------
        'set query string to "SELECT CustomerID FROM customerlist;"
        'while looping through query
            'set stringvar to current loop's CustomerID
    
            'Create directory
            If(Not System.IO.Directory.Exists("c:\pub\users\" & stringvar)) Then System.IO.Directory.CreateDirectory("c:\pub\users\" & stringvar)
            RichTextBox.AppendText(vbCrLf & "Added folder: " & stringvar)
            RichTextBox.ScrollToCaret()
    
        'end while loop
    

    to

    conn.Open()
    MessageBox.Show("Connection Opened Successfully")
    Dim command As New MySqlCommand("SELECT CustomerID from customerlist", conn)
            Dim stringvar As String
            Dim count As Integer = 1
    
            myReader = command.ExecuteReader
            While (myReader.Read())
                stringvar = myReader(0).ToString
    
                If (Not System.IO.Directory.Exists("c:\pub\users\" & stringvar)) Then
                    System.IO.Directory.CreateDirectory("c:\pub\users\" & stringvar)
                    TextBox.AppendText(vbCrLf & count & ":   Created folder for CustomerID: " & stringvar)
                    TextBox.ScrollToCaret()
                Else
                    TextBox.AppendText(vbCrLf & count & ":   Could *NOT* creat folder for CustomerID: " & stringvar)
                    TextBox.ScrollToCaret()
                End If
    
                count = count + 1
            End While
    

    Produced:

    CustomerID: 11112
    CustomerID: 11113
    CustomerID: 11114
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Question: I have a question that is apparently not answered by this already-asked Bash
Yes, I have already asked this question, but the problem is much more specific.
I have already googled for this I have a Table with following structure in
I just finished reading this post: https://developer.yahoo.com/performance/rules.html#flush and have already implemented a flush after
Outline OK, I have Google'd this and already expecting a big fat NO!! But
I have a feeling that I already know the answer to this one, but
There is a very common task I face again. I have already solved this
I have a .net/DirectX-based rendering library. At program start, we try to find out
Okay I've been trying to figure this out for a while now. I have
I have this piece of Javascript and it just won't work. I allready checked

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.