Mitja Bonca 557 Nearly a Posting Maven

Hi,
Check this link here: http://stackoverflow.com/questions/304337/post-data-to-a-php-page-from-c-sharp-winform?rq=1
Im sure you can find the answer there.

Mitja Bonca 557 Nearly a Posting Maven

Hi,
So now you salve the issue about Datetime?
-- --
Abour your last issue, not reading data.
Does the code go into while loop? (hint: put a break point and go line by line, this way you can check whats really going on).
And I would now use a while loop, if you only wanna show an image, better use if loop. Else you will always get shown the very last image regarding the select query (and its where clause).

Mitja Bonca 557 Nearly a Posting Maven

ups, sorry, I forgot your ids are string (varchars), not integers.
Try to change this code to:

DataRowView view = comboBox1.SelectedItem as DataRowView;
da.InsertCommand.Parameters.Add("@Town", SqlDbType.VarChar).Value = view["ID_Town"].ToString();

NOTE: And make sure "ID_Town" is the corrent name of the value member of comboBox!!!

Mitja Bonca 557 Nearly a Posting Maven

Yes, this is how it suppose to be done with the login checking. This is the correct way.

I dont know which file you use, and what is your data structure in it. So cant tell you more.
But I would suggest you something like (data strucure of txt file):

username;password

Semicolon is a delimiter between username and password. And you have to make sure of one thing when registering new user - DO NOT ALLOW to insert this delimiter in any case. And no matter which one it is.

Next you can read line by line and check login:

bool bValid = false;
using(StreamReader sr = new StreamReader("fileName.txt"))
{
    string line;
    while((line = sr.ReadLine()) != null)
    {
        string[] data = line.Split(';');
        if(data[0] == textBoxUsername.Text.Trim() &&
           data[1] == textBoxPassword.Text.Trim())
           {
                //login successful!!
                bValid = true;
                break;
           }
    }
}
if(bValid)
{
    //continue working, login was a success!!
}
else
{
    //show a message login was not successful!
}

Thisis it¨!

Mitja Bonca 557 Nearly a Posting Maven

Hi, fill DataTable with images from database (or where ever), an then do a loop throuh the rows of dgv, and paste image into each row (to each dgv_image_cell):

  //create image column
  DataGridViewImageColumn ic= new DataGridViewImageColumn();
  ic.HeaderText = "Images";
  ic.Image = null;
  ic.Name = "imageColumn";
  ic.Width = 100;
  dataGridView1.Columns.Add(ic);

 //then fill DataTable 
 //NOTE: Images should be in bytes saved into database!!!

 DataTable table = new DataTable();
 using(SqlConnection sqlcon = new SqlConnection("connString"))
 {      
     string strquery = "SELECT MyImageColumn FROM MyTable";  
     using(SqlDataAdapter da = new SqlDataAdapter(strquery, sqlcon))
     {
        da.Fill(table);
     }
 }
  //1.
  //now lets loop through the rows of dgv and add images from dataTable!
  //NOTE: BE CAREFUL on the number of rows in DGV, and in DataTable!!!
  //If they are not the same, create some conditions!!

  for(int i = 0; i < dataGridView1.Rows.Count; i++)
  {
      DataGridViewImageCell cell = table.Rows[i][ColumnName"] as DataGridViewImageCell;
      dataGridView1["imageColumn", i].Value = cell;
  }

  //OR:
  //2.
  //Lets loop through the rows of DataTable!
  //Be aware of the same issue as above - number of rows in both collections! 
  for(int i = 0; i < table.Rows.Count; i++)
  {
      DataGridViewImageCell cell = table.Rows[i][ColumnName"] as DataGridViewImageCell;
      dataGridView1["imageColumn", i].Value = cell;
  }

Hope it helps,bye

Mitja Bonca 557 Nearly a Posting Maven

Create a custon class. Inside of it create a method in which type this code of yours. Then instantiate the class ones, and pass (use) the referecne of class on multiple places to access to method (which will execute the sqlconnection and open it).

Mitja Bonca 557 Nearly a Posting Maven

1st of all, dont save - most for - password in a plain text. Use crypting.

Mitja Bonca 557 Nearly a Posting Maven

Could be.
Override mean you set some method as virtual,(in 1st class), then in next class you override it by using override keyword (in a method signiture).
While overload that you have in one (same) class more method with the same name, but with different signitures.

Mitja Bonca 557 Nearly a Posting Maven

1st of all, dont use any parenthesis.

next do:

"SELECT Member.MemberID, Member.Name , Member.Surname, Rentals.RentalID FROM Member, Rentals WHERE Member.MemberID = Rentals.MemberID AND Member.MemberID = @MemberID"

And define @MemberID parameter as you did (paramtreize query)

Mitja Bonca 557 Nearly a Posting Maven

use Console.WriteLine(); - on the end
if this is it.

Mitja Bonca 557 Nearly a Posting Maven

hi,
pass what exactly?

Mitja Bonca 557 Nearly a Posting Maven

great to hear that. It happens.
Just mark the thread as salved - in case if you didnt know that.
bye

Mitja Bonca 557 Nearly a Posting Maven

Hi, why do you wanna use selectedValue for Town field? There is actually no point, unless if you wanna get an id
of town. Else, use SelectedItem.
If you wanna get a value from comboBox - this means you defined display and value member and set datasouce for combobox.

To get a value you do:

DataRowView view = comboBox1.SelectedItem as DataRowView;
da.InsertCommand.Parameters.Add("@Town", SqlDbType.VarChar).Value = int.Parse(view["columnName"].ToString());
//this is if you want to get an integer - an id column defined as value member.

If you wanna get only display member only do:
// .. Value = view["displayMemberColumnName"].ToString();

Hope it helps.
bye

Mitja Bonca 557 Nearly a Posting Maven

Hi,
Did you add this namespace that you are getting an error?
Check here for more info: http://msdn.microsoft.com/en-us/library/system.windows.controls.listview.aspx

Mitja Bonca 557 Nearly a Posting Maven

Momerath is right. I suggest you to do a little search over this forum (or uncle google) and Im sure will will soon fine a good solution.
And btw, you are learning, not we. So we would like to see some attiture from you guys, not that only what you want is a working code from us.
Sorry.

Mitja Bonca 557 Nearly a Posting Maven

Before that do the select query, to check if this customerName exits of not. If does not exist, do Insert, else show a message box of existance.
Will it go?
It should be like:

protected void Button1_Click1(object sender, EventArgs e)
{
      string sql2 = @"SELECT CustomerName FROM user WHERE CustomerName = @name";
      SqlConn.Open();
      SqlCommand cmd = new SqlCommand(sql2, SqlConn);
      try
      {
          object objName = cmd.ExecuteScalar();
          if(objName == null)
          {
                string sql = "INSERT INTO user(CustomerName,Age,Sex,Email address,State,City,Country) VALUES (@Val1,@Val2,@val3,@val4,@val5,@val6,@val7,@val8,@val9,@val10)";       
                cmd = new SqlCommand(sql, SqlConn);
                cmd.Parameters.AddWithValue("@Val1", txtcname.Text.ToString().Trim());
                cmd.Parameters.AddWithValue("@Val2", txtAge.Text.ToString().Trim());
                cmd.Parameters.AddWithValue("@Val3", txtsex.Text.ToString().Trim());
                cmd.Parameters.AddWithValue("@Val4", txtEmail.Text.ToString().Trim());
                cmd.Parameters.AddWithValue("@Val5", txtaddress.Text.ToString().Trim());
                cmd.Parameters.AddWithValue("@val6", DrpState.SelectedItem.ToString().Trim());
                cmd.Parameters.AddWithValue("@Val7", DrpCity.SelectedItem.ToString().Trim());
                cmd.Parameters.AddWithValue("@Val7", DrpCountry.SelectedItem.ToString().Trim());
                cmd.CommandType = CommandType.Text;
                cmd.ExecuteNonQuery();
            }
            else
                MessageBox.Show("User already exists!");
      }
    catch (System.Data.SqlClient.SqlException ex)
    {
        string msg = "Insert Error:";
        msg += ex.Message;
        throw new Exception(msg);
    }
    finally
    {
        SqlConn.Close();
    }
}
Mitja Bonca 557 Nearly a Posting Maven

Did you salve the problem yet?

Btw:

and i am in a mess in getting my database connection to my datagridview

What should that suppose to mean exaclty?
Do you have problems with connection string, or with getting data from database to dgv?

Mitja Bonca 557 Nearly a Posting Maven

Did you set CommandTimeout?

Dim command As New SqlCommand(sqlQuery, _Database.Connection)
command.CommandTimeout = 10 'some value
Mitja Bonca 557 Nearly a Posting Maven

You should use DataRowView class to retreive item and value from comboBox:

Dim view As DataRowView = comboBox1.SelectedItem
Dim value As Object = view("ColumnNameForValueMember")
Dim item As Object = view("ColumnNameForDisplayMember")
textBox1.Text = item.ToString()

Put this code into comboBox SelectedIndexChanged event.

Mitja Bonca 557 Nearly a Posting Maven

Hi,
Would you mind showing as some code?

Check here this link if it helps: http://irslab.blogspot.com/2010/07/aforgenet-color-filter-c.html
thx

Mitja Bonca 557 Nearly a Posting Maven

Add "ToString()" method on the end:

comboBox1.SelectedItem.ToString();

To add: SelectedItem for it self is an object type, but I need to have a string.
You could even Convert to string like:

Convert.ToString(comboBox1.SelectedItem);
Mitja Bonca 557 Nearly a Posting Maven

How?
Simply.
You need one dataTable to Fill it with all Rents. Bind it to dgv1. So you can retreive MemberID_ForeignKey from it (use DataSource property).
I would personally hide this column (because its not good to view columns like ID).
Next...
When user clicks on some row of dgv1, get the MemberID_ForeignKey from DataTable1 (not frm dgv1, because this column is invisible - so no data will be found).
You can retreive value like (using Linq):

 //inside CellDoubleClick event:
    //NOTE: e.RowIndex is a property of this event!!
    int ID = int.Paarse(table1.AsEnumerable().Where(w = > (string)w["Value"].ToString() == e.RowIndex).Select(s => (int)s["MemberID_FK"].ToString()).FirstOrDefault().ToString());

Then based on this MemberID_FK value create a new sql query fill new DataTable, and bind it to dgv2. Use this value in Where clause. Query would be:

"SELECT * FROM Members WHERE MemberID = '" + ID + "'"  //ID is an integer from above!

Hope it helps now.

Mitja Bonca 557 Nearly a Posting Maven

Sure, in sql would be like:

tables:
1. Members: MemberID, Name, ....
2. Rents: MemberID_FK, Value,...

now to do an sql query to get all members that are in Rental table:

 "SELECT Members.MemberID, Member.Name FROM Members, Rents WHERE Members.MemberID = Rents.MembersID_FK"

But its not such a good idea to populate the same datagridview - especially from the view of number of columns.
Anyway, it sure is possible to do. Just populate datagridview manually for both queries (1st for all Rents, 2nd for Members that belongs to specific Rent).

Mitja Bonca 557 Nearly a Posting Maven

Check out this simple example, here you can see what polymoprhism is all about:

    class Program
    {
        static void Main(string[] args)
        {
            Car c = new BMW();
            c.Name();
            c = new Honda();
            c.Name();
            c = new Civic();
            c.Name();
            c = new CBR();
            c.Name();
            //1. sealed - when using a reference of base class:
            c = new CBR1000();
            c.Name();
            //2. sealed when using a reference of particular derived class:
            CBR1000 cbr1000 = new CBR1000();
            cbr1000.Name();
            Console.ReadLine();
        }
    }

    abstract class Car
    {
        public abstract void Name();
    }

    class BMW : Car
    {
        public override void Name()
        {
            Console.WriteLine("This is a BMW car.");
        }
    }

    class Honda : Car
    {
        public override void Name()
        {
            Console.WriteLine("This is a honda car. ");
        }
    }

    class Civic : Honda
    {
        public override void Name()
        {
            base.Name();
            Console.WriteLine("Model: Civic.");
        }
    }

    class CBR : Honda
    {
        public sealed override void Name()
        {
            Console.WriteLine("This is not a car. Its a Honda CBR motorbike. ");
        }
    }

    class CBR1000 : CBR
    {
        public new void Name()
        {
            base.Name();
            Console.WriteLine("Exactly a CBR 1000 model.");
        }
    }
Mitja Bonca 557 Nearly a Posting Maven

This is not an easy task to do. You will actually need to have two datatables filled.
1st for all Memebers - display them all in datagrdivirew
2nd for Rents - when clicked on some member, table will get filled every time, and will populate the rows bellow the memeber.

Important here is to populate dgv manually - so no data souce used. Add data row by row, column by column.
This way you can manually set "+" sign in 1st column. And then clicked (1st column clicked) fill new DataTable with data from Rent table (based on foreighn key from members).

Mitja Bonca 557 Nearly a Posting Maven

Remove parentheses from sql query this ( and this ).

Mitja Bonca 557 Nearly a Posting Maven

Here is my old calculator code:
PS: Add controls (buttons and textboxes on form - check which one are inside the code)

    public partial class Form1 : Form
    {
        decimal num1, total;
        int operation;
        bool bNewCalc;
        bool bNextNum;

        public Form1()
        {
            InitializeComponent();
            display.Text = string.Empty;
            textBox1.Text = "0";
            textBox1.TabStop = false;

            Button[] btns = new Button[] { button0, button1, button2, button3, button4, 
                                           button5, button6, button7, button8, button9, };
            foreach (Button  btn in btns)
                btn.Click += new EventHandler(Buttons_Click);
        }

        enum MathOperators
        {
            Multiplication = 0, // *
            Division = 1,       // /
            Addition,           // +
            Subtraction         // -
        }

        private void Buttons_Click(object sender, EventArgs e)
        {
            Button btn = sender as Button;
            if (btn != null)
            {
                if (bNextNum)
                {
                    textBox1.Text = btn.Text;
                    bNextNum = false;
                }
                else
                {
                    if (textBox1.Text.Equals("0") || bNewCalc)
                    {
                        textBox1.Text = btn.Text;
                        bNewCalc = false;
                    }
                    else
                        textBox1.Text += btn.Text;                    
                }
                num1 = int.Parse(textBox1.Text);
            }
        }

        private void buttonMul_Click(object sender, EventArgs e)
        {
            SetOnOperation("*");
            operation = (int)MathOperators.Multiplication;
        }

        private void buttonDiv_Click(object sender, EventArgs e)
        {
            SetOnOperation("/");
            operation = (int)MathOperators.Division;
        }

        private void buttonAdd_Click(object sender, EventArgs e)
        {           
            SetOnOperation("+");
            operation = (int)MathOperators.Addition;
        }

        private void buttonMin_Click(object sender, EventArgs e)
        {           
            SetOnOperation("-");
            operation = (int)MathOperators.Subtraction;           
        }

        private void SetOnOperation(string sign)
        {
            if (!bNextNum)
            {
                if (bNewCalc)
                    display.Text = String.Format("{0} {1}", total.ToString(), sign);
                else
                {
                    display.Text += String.Format("{0} {1} ", num1, sign);
                    bNextNum = true;
                    if (!total.Equals(0))
                    {
                        DoCalculation();
                        textBox1.Text = total.ToString();
                    }
                    else
                        total = decimal.Parse(textBox1.Text);
                }
            }
            else
                display.Text = String.Format("{0} {1} ", display.Text.Remove(display.Text.Length …
Mitja Bonca 557 Nearly a Posting Maven

Create a commone event for all the buttons, and then create a class variable (an integer type) and count when click event occures. When counter reashes 3, show a warning message, and reset it back to zero.
Will it go?

Mitja Bonca 557 Nearly a Posting Maven

WHERE Clause is the condition of what the inquiry will be based on.
If you do:
"SELECT * FROM MyTable" - it will return all data from database table (data are meant all rows, since we use * simbol)
If you do:
"SELECT * FROM MyTable WHERE Name = "John"; - it will return ONLY rows where in the Name column is John (same as your example).

This means the whole name "John" not only "Jon", or "J".

Maybe you entered only "J" or "Joh" and thats why you didnt get any results.
Thats why sql querying supporty partial values (or starting from beginning, or in form somewhere in the middle, or to the end).
Thats why we must use LIKE keyword and % simbol.
If you do:
... WHERE Name = 'J%' - will return all rows that STARTS with J
... WHERE Name = '&n' - will return all rows that ENDS with n
... WHERE NAme = '&hn&' - will return all rows that CONTAINS hn in some where in the middle!

I hope I was clear enough about using LIKE keyword in sql queries.
So I your case I assume you wanna get all rows that starts with some name, so you do:

 "SELECT * From DVD where Name LIKE ='" + txtName.Text + "%'";
Mitja Bonca 557 Nearly a Posting Maven

Better to use null as both arguments, then passing some Time parameters to button (2nd example from above is the one you need). But only in case when you will not need and parameters from EventArguments, or sender - but I doubt you will need).
Else you can create EventArguments manully.

Mitja Bonca 557 Nearly a Posting Maven

string is an alias for System.String. So technically, there is no difference. It's like int vs. System.Int32.

As far as guidelines, I think it's generally recommended to use string any time you're referring to an object. e.g.

Mitja Bonca 557 Nearly a Posting Maven

And you have to be aware of something else, by default radioButtons are meant to have one radio (1st one normally) checked. They are meant that one of them (from a group) is always checked.
To avoid this, you have to uncheck the 1st one.

Mitja Bonca 557 Nearly a Posting Maven

Freedom - PLEASE next time you write into here, define EXACTLY what you wound want from this project to do. But I mean exactly - not "this is what I want it to do", or "yes, random scores".

We dont know now what to think, you saw me I have guessed what you had been thinking about.

Mitja Bonca 557 Nearly a Posting Maven

But it has no point in this.
Points are (in my opinion) the points -for football (in europe):
3 - for winning
1- for equal
0 - for loosing

---

So really dont see the point in using Random, only in case if he want to shuffle teams in between to create, lets says, some kind of championship.
Who knows... :)

Mitja Bonca 557 Nearly a Posting Maven

Why would you use Random class exactly? I dont see a point. To randomly shuffle teams between ?

Mitja Bonca 557 Nearly a Posting Maven

Indeed, you code does not return some value on each possible step of the method.
Change it to:

         public bool GetAdministrators(string userName, string password)
        {
            SqlConnection conn = new SqlConnection("Data Source=(local); database=ManagementNAV; Integrated Security=True");
            SqlCommand cmd = new SqlCommand("GetAdministrators", conn);
            cmd.CommandType = CommandType.StoredProcedure;
            conn.Open();
            SqlDataReader reader = cmd.ExecuteReader();
            bool bFlag = false;
            while (reader.Read())
            {
                if (reader["userName"].ToString() == userName && reader["password"].ToString() == password)
                {
                    bFlag = true;
                    break;
                }
            }
            reader.Close();
            return bFlag;
        }
Mitja Bonca 557 Nearly a Posting Maven

And put this code into a loop.

Mitja Bonca 557 Nearly a Posting Maven

You can simply remove all what us after parenthesis:

Dim str As String = "user1 pass (111.222.333)"
str = str.Remove(str.IndexOf("("C))
Mitja Bonca 557 Nearly a Posting Maven

Ups, sorry, you are right. I copied the previous code, and I guess forgot to duble check it.
My intentions were good....

Mitja Bonca 557 Nearly a Posting Maven

What do you mean "Prompt the form name"?
And btw instead of returing string, rather return a boolean values - true of false.

Mitja Bonca 557 Nearly a Posting Maven

Hmm, some strange code you have there. I have commented all what is strange insid changed code bellow:

Public Function ShowData(Query As String) As DataTable
    Dim dt As New DataTable("myTable")
    Using con As New SqlConnection(My.Settings.DatabaseICICIConnectionString)
        Dim da As New SqlDataAdapter(Query, con)
        da.Fill(dt)
        da.Displose()
    End Using
    Return dt
End Function

Public Sub LoadFields()
    Dim dt As DataTable = ShowData("Select ColumnName FROM MyTable Where SOME CONDITION IF NEEDED")
    'if no condition, remove from where on!
    Dim dc As New DataColumn()
    For Each dc As DataColumn In dt.Columns
        'What are you trying to do here?
        'and only columns name s to comoobox? Is so do:         
        cboFields.Items.Add(dc.ColumnName)
    Next
End Sub
Mitja Bonca 557 Nearly a Posting Maven

Use DataReader class and Add items to comboBox:

Dim connString As String = "Provider=Microsoft.ACE.OLEDB.12.0;data source=C:MyFolder\MyProject\myAccessDatabase.accdb"
Dim conn As New OleDbConnection(connString)
Dim sql As String = "SELECT ColumnName FROM Clientes"
Dim cmd As New OleDbCommand(sql, conn)
conn.Open()
Dim reader As OleDbDataReader = cmd.ExecuteReader()
While reader.Read()
    comboBox1.Items.Add(reader(0).ToString())
End While
reader.Close()
conn.Close()
cmd.Close()
Mitja Bonca 557 Nearly a Posting Maven

I would like you to continue using Linq, which is really some piece of work from MS.

To get 1st 50 words:

string text = "you long string";
var result_1st50 = text.Split(' ').Select(s=>s.Lenght).Take(50).ToList();

To get next 50 (and skip 1st 50):

var result_1st50 = text.Split(' ').Select(s=>s.Lenght).Skip(50).Take(50).ToList();

As you can see, Skip will skip the number of words, while Take will get the number of words. For example if you wanna get words from 350 to 400, you only change:
//.Skip(350).Take(50).ToList();

ToList() is the annonimus method, that already create a new list of strings, so no need of any further loop.

Mitja Bonca 557 Nearly a Posting Maven

Sorry, here is C# version:

//using System.Data;
//using System.Data.OleDb;
//in your method:

{
    OleDbConnection con = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Book1.xls;Extended Properties=Excel 8.0");
    OleDbDataAdapter da = new OleDbDataAdapter("SELECT * FROM  YourSheetName", con);
    DataTable dt = new DataTable();
    da.Fill(dt);
    //create a list, to put all employee IDs that didnt pay House allowance:
    List<string> _ids = table.AsEnumerable().Where(w => string.IsNullOrEmpty((string)w["house allowence"])).Select(s => (string)s["id"]).ToList();
    //
    //this is my whole example, so you can see what I mean!
    //the result is 2 and 4:
    DataTable table = new DataTable();
    table.Columns.Add("id", typeof(string));
    table.Columns.Add("house allowence", typeof(string));
    table.Rows.Add("1", "34");
    table.Rows.Add("2", "");
    table.Rows.Add("3", "12");
    table.Rows.Add("4", "");
    List<string> ids = table.AsEnumerable().Where(w => string.IsNullOrEmpty((string)w["house allowence"])).Select(s => (string)s["id"]).ToList();
}
Mitja Bonca 557 Nearly a Posting Maven

The simpliest way would be to spit the string by white spaces into string array, and count the words (by Length property):

string text = "you long string";
string[] splitted = text.Split(' ');
int wordsCount = splitted.Length;

Or even better (shorter), by using Linq:

int a = text.Split(' ').Select(s => s.Length).Count();
coder389 commented: Now, how will I display the first 50 words, then next 50 words and so on? +0
Mitja Bonca 557 Nearly a Posting Maven

So you work witj excel file?
Next time be more precise about the issue, ok?

So in your file (and in some worksheet) you have columns EmpID, House allowence, and others.
So you wanna check which employee doesnt have any record?
You can use OLEDB provider, and fill DataTable, and check

'using System.Data;
'using System.Data.OleDb;

'in your method:
Dim con As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Book1.xls;Extended Properties=Excel 8.0")
Dim da As New OleDbDataAdapter("SELECT * FROM  YourSheetName", con)
Dim dt As New DataTable()
da.Fill(dt)

'create a list, to put all employee IDs that didnt pay House allowance:
Dim _ids As List(Of String) = table.AsEnumerable().Where(Function(w) DirectCast(w("house allowence"), String) = "").[Select](Function(s) DirectCast(s("id"), String)).ToList()

'
'this is my whole example, so you can see what I mean!
'the result is 2 and 4:
Dim table As New DataTable()
table.Columns.Add("id", GetType(String))
table.Columns.Add("house allowence", GetType(String))
table.Rows.Add("1", "34")
table.Rows.Add("2", "")
table.Rows.Add("3", "12")
table.Rows.Add("4", "")
Dim ids As List(Of String) = table.AsEnumerable().Where(Function(w) DirectCast(w("house allowence"), String) = "").[Select](Function(s) DirectCast(s("id"), String)).ToList()
Mitja Bonca 557 Nearly a Posting Maven

I would go for a Dictionary<Tkey, Kvalue>, where Tkey will be row index, and Kvalue will be a List<T (and T in a list will be an integer>.
Of course, all this will be done when reading a file, row by row:

    using System.IO;

    private void buttonGetData(object sender, EventArgs e)
    {
        string filePath = @C:\Myfolder\Myfile.txt";
        Dictionary<int, List<int>> dic = GetDataFromFile(filePath);
        //show:
        StringBuilder sb = new StringBuilder();
        foreach(KeyValuePair<int, List<int>> kvp in dic)
        {            
             sb.Append(stirng.Format("line {0}, Items: ", kvp.Key));
             foreach(int item in kvp.Values)
                 sb.Append(string.Format("{0}, ", item);
             sb.AppendLine();
        }
    }

    private GetDataFromFile(string filePath)
    {
        Dictionary<int, List<int>> dic = new Dictionary<int, List<int>>();
        int counter = 1;           
        foreach(string item in ReadingFile(filePath)
        {
            string[] data = item.Split(' ');
            dic.Add(counter, new List<int>());
            foreach(string item in data)
                 dic[counter] = int.Parse(item);
             counter++;
        }
    }

    private IEnumeravble<string> ReadingFile(string filePath)
    {
        using(StreamReader st = new StreamReader(filePath))
        {
            string line;
            while((line = sr.ReadLine()) != null)
            {
                yiled return line;
            }
        }
    }
Mitja Bonca 557 Nearly a Posting Maven

You should consider a bit differently. 1st check only the login data (if username exists in database, and if password matched to this users).
Next comes to check the status of the users.

Login check:

Dim category As String          
'class variable so you can then set things based on it

    Private Sub buttonLogin_Click(ByVal sender As Object, ByVal e As EventArgs)
        category = Nothing
        Dim login As String = Me.textBoxUsername.Text
        Dim password As String = Me.textBoxPswd.Text
        Dim u As String = ("SELECT UserName,Password, Category FROM Students WHERE UserName ='"  _
                    + (login + "'"))
        Dim sql_conn As SqlConnection = New SqlConnection("connString")
        Dim cmd As SqlCommand = New SqlCommand(u, sql_conn)
        Dim rd As SqlDataReader
        Dim valid As Boolean = false
        Try 
            Sql_conn.Open
            rd = cmd.ExecuteReader

            While rd.Read
                If (password = rd("Password").ToString) Then
                    valid = true
                    category = rd("Category")
                    Exit While
                End If

            End While
            Exception
            ex
            'show an error if needed
            rd.Close
            Sql_conn.Close
        End Try
        Dim SettingStuff As System.Void
        If (caregory Is Nothing) Then
            MessageBox.Show("Please login before using form.")
        ElseIf (category = "Admin") Then
            'set for admin
        ElseIf (category = "Stuff") Then
            'set for stuff
        End If
    End Sub
Mitja Bonca 557 Nearly a Posting Maven

You have to get an image from database to byte array, and with StreamReader then pass it to pictureBox:

Dim ImageByte As Byte() = Nothing
Dim MemStream As MemoryStream = Nothing
Dim PicBx As New PictureBox()
Dim OB As Object
Dim WorkingDirectory As String = Application.StartupPath + "\"
connString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & WorkingDirectory & "DBFile.mdb; Persist Security Info=True"
cnction = New OleDbConnection(connString)
cnction.Open()
Dim ImageID As Integer = 6
sqlCommand = "SELECT ImageObject FROM ImagesTable WHERE ImageID = " & ImageID & ""
comm = New OleDbCommand(sqlCommand, cnction)
ImageByte = comm.ExecuteScalar()
MemStream = New MemoryStream(ImageByte)
PictureBox1.Image = Image.FromStream(MemStream)
Mitja Bonca 557 Nearly a Posting Maven

What does the Exception say? The error message?
But based on your description, there is no error, so it means that the data are inserted into datatabe - but you cannot see the insertions, since this database is attached to your project.
Try to write the full path to the database, instead of using |DataDirectory|.