Mitja Bonca 557 Nearly a Posting Maven

Not true, it wont help.
This is what you can try:

da.Fill(ds,"myTable");
dgv1.DataSource = new BindingSource(ds.Tables["myTable"], null); //but the same as using names is using table indexes, like you did!
Mitja Bonca 557 Nearly a Posting Maven
Dim n As New Login()
n.Show()
Mitja Bonca 557 Nearly a Posting Maven

What is that part "wow test" doing there? There is no pattern for this text.
So hard to do it simply.
What do you think?

Mitja Bonca 557 Nearly a Posting Maven

You can specify some date, like today (but you have to be aware that Today property does not set any day time, it is actually, but it sets to 00:00:00 "hh:mm:ss"), so then you can add 7 days to this date, and check if this date is a new date:

DateTime date1 = new DateTime(2011,8,3);
if(date1.AddDays(7) == new DateTime(2011, 8 10))
{
    //notify the user that 7 days has passed!
}
Mitja Bonca 557 Nearly a Posting Maven

1st you need to create columns, then you fill the row (by looping through rows of dgv):

DataSet ds = new DataSet();
DataTable table = new DataTable("DataFromDGV");
//if you have only one table, it pointless to create a dataSet
//dataSet is used as a collection of more-then-one dataTable
//so you can do:
ds.Tables.Add(table);
//create columns:
foreach(DataGridViewColumn col in dgv.Columns)
     table.Columns.Add(col.HeaderText, typof(string));
//fill the rows of table:
foreach (DataGridViewRow row in dataGridView1.Rows)
{
     foreach (DataGridViewCell cell in row.Cells)
     {
          table.Rows[row.Index][cell.ColumnIndex] = cell.Value;   
     }          
}
Mitja Bonca 557 Nearly a Posting Maven

Check this out:

Private r As New Random()
Private list As List(Of String)
Public Sub New()
	InitializeComponent()

	comboBox1.Items.Add("--- select ---")
	list = New List(Of String)() From { _
		"item 1", _
		"item 2" _
	}
	For Each item As String In list
		comboBox1.Items.Add(item)
	Next
End Sub

Private Sub button1_Click(sender As Object, e As EventArgs)
	comboBox1.SelectedItem = list(r.[Next](list.Count))
End Sub

Private Sub button2_Click(sender As Object, e As EventArgs)
	comboBox1.SelectedIndex = 0
End Sub
Mitja Bonca 557 Nearly a Posting Maven

dbgrid?
Can you tell a more please? Why you are all so shy?
Dont expect any help with this kind of manner guys.

Mitja Bonca 557 Nearly a Posting Maven

Great. If this is it, you can complete the thread with setting it as answered.
If not, you can still ask questions ,regarding the thread`s topic.
Best regards,

Mitja Bonca 557 Nearly a Posting Maven

Use ExecuteNonQuery() method, instead of ExecuteScalar().
ExecuteScalar() method in only used to get, set only one value.

Mitja Bonca 557 Nearly a Posting Maven

You have only declared the two dimensionaly array, but you didnt initialize it.
Try to insert this line of code:

position = new int[1, 1]; //insert this line - to initialize new array!
 position[xx, yy] = foo.bar_name;// reason of error
 position[xx, yy] = load_position(x, y);
Mitja Bonca 557 Nearly a Posting Maven

You said, you want to get data into a listView, am I right?
So create columns (as many as you want, based on array number of data from the file), and use ListViewItem class to populate listView (use Text property for the 1st item, and Subitems.Add() method for the rest of th columns).

Will it go?

Mitja Bonca 557 Nearly a Posting Maven

Try it this way:

Dim days As Integer = 12 'your value from DB! (one or the other - didnt know what you want
Dim months As Integer = 5 'your value from DB!
Dim [date] As DateTime = DateTime.Now 'some date !

'get new date (current date + days):
[date] = [date].AddDays(days)

'get new date (current date + months):
[date] = [date].AddMonths(months)
Mitja Bonca 557 Nearly a Posting Maven

What the code outputs now? Is it not ok? tell us whats wrong.

Mitja Bonca 557 Nearly a Posting Maven

Would you mind showing us the code you got there? Maybe we can figure something out.
And tell us your logic about fasering the procedure of file creation.

Mitja Bonca 557 Nearly a Posting Maven

Momerath had to point. What does it take so much to co create 100 files?
Next - if your code (and computer) is capable of 100 per 10 minutes, then this is it! You actually cant make the same files two times faster.

Mitja Bonca 557 Nearly a Posting Maven

Process.Start(); executes the code to start some application or something.

Dim myProcess As System.Diagnostics.Process = System.Diagnostics.Process.Start("Notepad")

will start the Notpad.
What did you mean to start?

Mitja Bonca 557 Nearly a Posting Maven

This one would be a better choice:

Private Sub button1_Click(sender As Object, e As EventArgs)
	ExecuteMyCode(textBox1.Text)
End Sub

Private Sub ExecuteMyCode(text As String)
	If text.Contains("me.text") Then
		Dim array As String() = text.Split("="C)
		Me.Text = array(1)
	Else
		MessageBox.Show(text)
	End If
End Sub
Mitja Bonca 557 Nearly a Posting Maven

Ok, I have choosen a button click, but you can easiy use this code in TextChanged event too:

UPDATED:

Private Sub button1_Click(sender As Object, e As EventArgs)
	ExecuteMyCode(textBox1.Text)
End Sub

Private Sub ExecuteMyCode(text As String)
	Dim data As String() = text.Split(" "C)
	If data.Length > 1 Then
		Select Case data(0)
			Case "msgbox.show"
				MessageBox.Show(data(1))
				Exit Select
			Case "me.text"
				Me.Text = data(1)
				Exit Select
			Case Else
				'do nothing is non of above
				Exit Select
		End Select
	Else
		MessageBox.Show("Data is missing to show.")
	End If
End Sub

Still some work to do on to show correct result! We need to gather data!

Mitja Bonca 557 Nearly a Posting Maven

On a button click or on textChnaged event?

Mitja Bonca 557 Nearly a Posting Maven

Do you have any custom class for all this object?
If would be good to have it.
At least you can show us the code you have, and what would you like to change (comment it).

Mitja Bonca 557 Nearly a Posting Maven

I assume you are dealing with Access database, thats why you are trying to use question marks (???) when defining Values(in here), righ?
Correct way, only some part is missing.
You actually have to specifry the column names and not using question marks. Questio marks are only used in Update statement.

Mitja Bonca 557 Nearly a Posting Maven

Do you type in textBox both vlaues?
So your textbox after finishing writing looks like:

textbox "label1.text = "bla bla"" "msgbox.show"

With or without quotation marks?

Mitja Bonca 557 Nearly a Posting Maven

This is getting pointeless mate!
For UPDATE statement you do:
UPDATE tableName SET Field1 = @param1, Fields2 = @param2 WHERE idFields = @paramID

adam_k commented: :D +6
Mitja Bonca 557 Nearly a Posting Maven

INSERT statement should go like:
INSERT INTO DataBaseTable VALUES (value1, value2, ...)

So, yours statement is incorrect.

Mitja Bonca 557 Nearly a Posting Maven

Is it Express version?

Mitja Bonca 557 Nearly a Posting Maven

What kind of dataBase?
If you know which one you have, check for the correct conn. string here.

Mitja Bonca 557 Nearly a Posting Maven

It means your value can NOT be converted to float. Its just not that object to cast.
Set break point, and go to check what kind of value has "strUntitPrice".

Mitja Bonca 557 Nearly a Posting Maven

If column is marked as Primary Key, then is not chance of having two same values at all.
But what you can do, is to change the type of the primary key column to varchar, and add some character to the actual id, like A or B.

Exmple:
if id is a "number" like 1,2,3 and so on, save is as varchar, but with additional char like A1 or B1 (but as varchatr I repaet - so "A1", "B1", "B2,).
This way you will know from which table it is.

I dont really know why would you have it like this. Personally I would not do something like it at all. I would create two seperate tables - each per TableA and TableB (as auxiliary tables).

Mitja Bonca 557 Nearly a Posting Maven

Where, on which line of code this error appears? Please use a break point.

Mitja Bonca 557 Nearly a Posting Maven

Here you go:

public Form1()
        {
            InitializeComponent();
            //adding some example columns:
            //1. column is checkBox, rest of 2 are some usual column:

            DataGridViewCheckBoxColumn checkColumn = CreateCheckBoxColumn();
            dataGridView1.Columns.Add(checkColumn);
            dataGridView1.Columns.Add("col2", "Column 2");
            dataGridView1.Columns.Add("col3", "Column 3");

            //adding some example rows:
            for (int i = 1; i <= 10; i++)
            {
                dataGridView1.Rows.Add(false, "item A" + i, "item B" + i);
            }

            //create an event:
            dataGridView1.CurrentCellDirtyStateChanged += new EventHandler(dataGridView1_CurrentCellDirtyStateChanged);
            dataGridView1.CellValueChanged += new DataGridViewCellEventHandler(dataGridView1_CellValueChanged);
        }

        private DataGridViewCheckBoxColumn CreateCheckBoxColumn()
        {
            DataGridViewCheckBoxColumn column = new DataGridViewCheckBoxColumn();
            {
                column.Name = "checkColumn";
                column.HeaderText = "Select rows";
                column.AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells;
                column.ThreeState = false;
            }
            return column;
        }

        void dataGridView1_CurrentCellDirtyStateChanged(object sender, EventArgs e)
        {
            if (dataGridView1.IsCurrentCellDirty)
                dataGridView1.CommitEdit(DataGridViewDataErrorContexts.Commit);
        }

        private void dataGridView1_CellValueChanged(object obj, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == dataGridView1.Columns[0].Index) //compare to checkBox column index
            {
                foreach (DataGridViewRow row in dataGridView1.Rows)
                {
                    if (!row.IsNewRow)
                    {
                        DataGridViewCheckBoxCell checkBox = dataGridView1[0, row.Index] as DataGridViewCheckBoxCell;
                        if (checkBox != null)
                        {
                            if ((bool)checkBox.Value == true)
                                dataGridView1.Rows[row.Index].Selected = true;
                            else
                                dataGridView1.Rows[row.Index].Selected = false;
                        }
                    }
                }
            }
        }
ddanbe commented: Nice +14
Mitja Bonca 557 Nearly a Posting Maven

Try to chanve dateChanged with dateSelectec event.!

Mitja Bonca 557 Nearly a Posting Maven

Use a debugger. Put a break point to see if dataTable gets filled up!
My guess is that it does not. So there is something or with sql query (query statement, so it does no select from correct table (or this one is empty)), or maybe with conn.String (but if it would be it, there will be an exception thrown out.

Best is to go through the code line by line, and check dataTable has any values. This is the most I can say right now.

Mitja Bonca 557 Nearly a Posting Maven

On each button click you would like to increment it by 5?
Or what is that for loop there?

Mitja Bonca 557 Nearly a Posting Maven

It would be better to use datasource property of comboBox to pass data from table to comboBox:

Private Sub Form5_Load(sender As System.Object, e As System.EventArgs)
	Dim con As New SqlConnection()
	con.ConnectionString = "Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\lito\Documents\QMP_DB.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"
	con.Open()
	Dim da As New SqlDataAdapter("select * from Subject_Info", con)
	Dim table As New DataTable()
	da.Fill(table)
	comboBox1.DataSource = New BindingSource(table, Nothing)
	comboBox1.DisplayMember = "Name"
	'write the column name which will be diplayed
	'you can even use  valueMember property, 
	'Names - DisplayMember - this is was you see in comboBox
	'IDs - ValueMember can be used as additional value of Person
	comboBox1.ValueMember = "ID"
	'column name for value         
End Sub
debasisdas commented: agree +13
adam_k commented: You've got it +6
Mitja Bonca 557 Nearly a Posting Maven
//1. to get a total of LastBalace:
"SELECT SUM(LastBalance) FROM Students";

//2. to get the last LastBalance 
"SELECT MAX(LastBalance) FROM Students";

//3. to get a specifc lastBalance
"SELECT LastBalance FROM Students WHERE StudentID = @id";
//pass an integer value to @id parameter!
/use SqlCommand(of OleDbCommand for Access) class.

//And use SqlDataReader class to read the value!
yousafc# commented: best answer +3
Mitja Bonca 557 Nearly a Posting Maven

I have a Textbox named txtage.text.Now I want When Insert in txtage.text as 30/12/1980.
disable tabindex.and messagebox show "You can not give admission".If Insert in txtage.text as 30/12/2005.
Enable Tab index .its mean student 's age must be 6 year not greater nor less.

1st of all, your post in not clear. Make is so, if you wanna help from us.
About what/which tabIndexes are you talkin about?

And when you work with dates, its best to use a control which is meant for it - so dateTimePicker as ddanbe told you.

Mitja Bonca 557 Nearly a Posting Maven

Chibex64: I'm having a problem on getting the fileinfo. The problem is stated above. I can't seem to figure out what's wrong. I'm kinda new to developing an audio and video file converter. :( Can you help me, please?

Would you look into my example code? There is explained all in the code.

Mitja Bonca 557 Nearly a Posting Maven

Hi, try this code bellow, but just make sure the DateTims are do not have hours, minutes or seconds. They onlymust have days, months and years (hours, minutes and seconds must be on zero, like "7.11,2011 0:00:00".

Private Sub Method()
	Dim dates As DateTime() = New DateTime(2) {}
	dates(0) = New DateTime(2011, 7, 10)
	dates(1) = New DateTime(2011, 7, 11)
	dates(2) = New DateTime(2011, 7, 13)

	Dim bCheckDates As Boolean = CheckConsecutiveDates(dates)
	If bCheckDates Then
		MessageBox.Show("Dates are consecutive.")
	Else
		MessageBox.Show("Dates are NOT consecutive.")
	End If
End Sub

Private Function CheckConsecutiveDates(dates As DateTime()) As Boolean
	Dim bChecking As Boolean = True
	For i As Integer = 0 To dates.Lengh - 1
		If i + 1 < dates.Lenght Then
			If dates(0).AddDays(1) <> dates(i + 1) Then
				bChecking = False
				Exit For
			End If
		End If
	Next
	Return bChecking
End Function
Mitja Bonca 557 Nearly a Posting Maven

Is the connection string correct?
And you really sure that name and password are really ok,and that the user exists in db?

Mitja Bonca 557 Nearly a Posting Maven

Just dont use 10 labels to write all. Use a StringBuiler class as I showed in the example.
And the calculation is a bit specific too (maybe not so much for experts), but the Lenght of the file is type of Long, so when you will double divide by 1024, you will get 0 (long does not have decimals). So box it as decimal, and it will do - as shown in example!

Mitja Bonca 557 Nearly a Posting Maven

If you selected only one file, you dont need a foreach loop. You use it when you have multiple files.
So what you can do is this:

public Form1()
        {
            InitializeComponent();
            label1.Text = "";
        }

        private void button1_Click(object sender, EventArgs e)
        {
            OpenFileDialog open = new OpenFileDialog();
            open.Filter = "Image Files(*.png; *.jpg; *.bmp)|*.png; *.jpg; *.bmp";
            open.InitialDirectory = @"C:\";
            if (open.ShowDialog() == DialogResult.OK)
            {                
                System.IO.FileInfo fInfo = new System.IO.FileInfo(open.FileName);
                StringBuilder sb = new StringBuilder();
                sb.AppendLine("File`s specifications are:\n");
                sb.AppendLine("Full file path: " + fInfo.FullName);
                sb.AppendLine("Full file name: " + fInfo.Name);
                sb.AppendLine("File name only: " + System.IO.Path.GetFileNameWithoutExtension(fInfo.FullName));
                sb.AppendLine("File extenstion: " + fInfo.Extension.ToString().Substring(1, fInfo.Extension.Length - 1)); //removing dot infront of extension!
                sb.AppendLine("File lenght: " + (String.Format("{0:0.00} MB", (((decimal)fInfo.Length / 1024) / 1024))));
                //you can add some more file`s properties if you want simply...
                label1.Text = sb.ToString();
            }
        }
Mitja Bonca 557 Nearly a Posting Maven

You can simply disable textBox:

txtage.Enabled = false;
Mitja Bonca 557 Nearly a Posting Maven

hehe, np.
About that method which generates random numbers, it has to be like this:

private List<int> GenerateRandomNumbers(int maxValue, int NumbersToGet)
        {
            List<int> list = new List<int>();
            int number = 0;
            for (int i = 0; i < NumbersToGet; i++)
            {
                do
                {
                    number = r.Next(maxValue);
                }
                while (list.Contains(number));
                list.Add(number);
            }
            return list;
        }

Correct it. And up there you have a full solution!

Mitja Bonca 557 Nearly a Posting Maven

You got it :)

Mitja Bonca 557 Nearly a Posting Maven

YOu know what... I was only trying to help him, because I knew he would have come back and asking me for more info, how this, how that, and so on...
Thats why I decided to give him a code, to see exactly what he needs.

But ok, from now on, I will keep of giving people code in this kind of manner. But still no need to down voting my post.

Mitja Bonca 557 Nearly a Posting Maven

... the additional columns I want to display are flatNo, houseNo and street

Where do you hold these data?

Mitja Bonca 557 Nearly a Posting Maven

pyTony: Why not? I did nothing wrong. I pasted the solution here, and because I thought he might have difficulties to run the whole thing, gave him a link to the full project!!


And please remove your down vote. I worked hard for you to ruin all?

You come here, do some short (pointless post) and then you will judge us here? You could tell me if you have something to tell.
Shame on you then...

Mitja Bonca 557 Nearly a Posting Maven

Ok, here we go...
I did the whole project for you. I will upload the solution in here, but you can download the full project HERE, so you can test it out. I hope I included all - most of the things I though they are important.

Code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace Jul25_1
{
    public partial class Form1 : Form
    {
        Random r = new Random();
        DataTable table1;
        DataTable table2;
        List<DataRow> rowsToRemove;

        public Form1()
        {
            InitializeComponent();            
        }

        private void buttonNewShuffle_Click(object sender, EventArgs e)
        {
            Get_100_RandomNumbes();
        }

        private void buttonGet20_Click(object sender, EventArgs e)
        {
            Get_20_SelectedNumbers();
        }

        private void buttonDelete_Click(object sender, EventArgs e)
        {
            DeleteRowsFromTable1();
        }
       
        private void Get_100_RandomNumbes()
        {
            table1 = new DataTable("table1");
            listBox2.DataSource = null;
            listBox2.Items.Clear();
            table2 = null;

            //I will use only one column, but the same is if you use more!
            table1.Columns.Add("Column 1", typeof(int));          

            //lets add some rows:
            for (int i = 0; i < 100; i++)
                table1.Rows.Add(i);
            
            //set data to listBox1:
            listBox1.DataSource = new BindingSource(table1, null);
            listBox1.DisplayMember = "Column 1";
        }

        private void Get_20_SelectedNumbers()
        {
            if (table1 != null)
            {
                if (table1.Rows.Count == 100)
                {
                    table2 = new DataTable("table2");

                    //create same column names as table1
                    table2 = table1.Clone();

                    int allRows = table1.Rows.Count; //total rows of table one
                    int myPick = 20;//You can use : r.Next(table1.Rows.Count); // this is your variable of how many rows random numbers to get!

                    List<int> myRandoms = GenerateRandomNumbers(allRows, myPick);

                    rowsToRemove = new List<DataRow>(); …
TrustyTony commented: Don't spoonfeed solutions. -3
Mitja Bonca 557 Nearly a Posting Maven

??
Do you know how to use debugger with break point? I hope so, so use it. Go through the code line by line to see where is the problem.

Mitja Bonca 557 Nearly a Posting Maven

Yep, as nmaillet showed. You have two option, or to access to class`s constructor (his 1st upper example), or to access any of your methods in your base class (his 2nd example).