This can be done with your database. Since you can have a "control id" autonumbered into the database, all you need to do is tell the program that you need a new record and pull the newest number from the database as the record is created. This is already implemented in access and SQL/TSQL/MySQL.

[QUOTE=ninjatalon;1479320]After closing the forms you will lose all data because all that data was just saved in memory therefore its only temporary. What you want to do is save that data into a database[/QUOTE]

The other option is to save the information to a CSV file or XML file as to hold the information. Then use a subroutine to load the information on FORM LOAD. This is easy to implement and there are multiple threads in this forum that cover this same information. There is other methods to do this. But a file is easy to deploy and does not need admin privileges to implement. If your issues are resolved please mark the thread as solved.

commented: :) better advice that i thought of +1

Reload the 1.1 .net or just upgrage to a newer one that contains the same information under systems.web.ui

[QUOTE=Unhnd_Exception;1451152]The problem is when there are groups and the initial state is Tile

Switching from Tile to Details is causing the Group to be behind the column headers.

I modified your code to show the problem

[code]
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Me.Load
ListView1.View = View.Tile
Dim sDir As String = "C:\"
Dim dDir As New DirectoryInfo(sDir)
Dim fFileSystemInfo As FileSystemInfo
ListView1.Columns.Add("Files")
ListView1.Columns.Add("Attributes")

    ListView1.Groups.Add(New ListViewGroup("0", "Group1"))

    For Each fFileSystemInfo In dDir.GetFileSystemInfos()
        ListView1.Items.Add(fFileSystemInfo.Name)
        ListView1.Items(ListView1.Items.Count - 1).Group = ListView1.Groups(0)
    Next

End Sub

Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
    Select Case ComboBox1.SelectedIndex
        Case 0
            ListView1.View = View.Details
        Case 1
            ListView1.View = View.Tile
    End Select
End Sub

[/code]

Run that and see if the group is behind the column headers when you switch.

If it is you can click on the first item in the list and the group will magically appear.[/QUOTE]

I think that this is a bug that happens. I have the program loaded on XP and Server 2003 and it works fine. I am not sure what is causing this to happen.

[QUOTE=dougancil;1451142]and when I add your code, intellisense tells me that Rows is not a member of System.Data.Data.Set[/QUOTE]

[CODE]
ds.Tables(0).Rows.Count
[/CODE]

Sorry I for got to specify the table lol

Here is a sample that I generated that works well for view switching using a combobox an loads with the form. All works well without issues, and it works with directory files. It switches the look upon change of the combobox. inside the combobox is items Details, List in that order. I hope this helps

[CODE]
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    ListView1.View = View.Details
    Dim sDir As String = "C:\\"
    Dim dDir As New DirectoryInfo(sDir)
    Dim fFileSystemInfo As FileSystemInfo
    ListView1.Columns.Add("Files")
    ListView1.Columns.Add("Attributes")

    For Each fFileSystemInfo In dDir.GetFileSystemInfos()
        ListView1.Items.Add(fFileSystemInfo.Name)

    Next

End Sub

Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
    Select Case ComboBox1.SelectedIndex
        Case 0
            ListView1.View = View.Details
        Case 1
            ListView1.View = View.List
    End Select
End Sub

[/CODE]

[QUOTE=dougancil;1451113]Zinnqu,

I actually found the code on another form that was causing this error. The debug was deceptive and was telling me that the break was happening before it actually was. I removed the code and the page works, but I'm still not seeing the msgbox when I have no data. It was suggested to me to remove the "into" portion of the sql query, which I did, to no avail.[/QUOTE]
Into was not the issue, the message part is missing the or statement that I gave you

[CODE]
if (ds is nothing) or (ds.rows.count = 0) then
[/CODE]

even if ds returns a 0 it will logically pass the "is nothing" part of the test because 0 is a placeholder to any .NET language. Try that. If not we can give it code to force the exemption before the test.

[QUOTE=MaddTechwf;1450971]Okay. Sorry zinnqu. I misread it. My apologies.[/QUOTE]
It's alright. If this helped, please mark the thread as solved and Vote.

[QUOTE=MaddTechwf;1450203]@zinnqu - Why is it not an option? I've seen other VB.NET compiled programs that can call it. They just didn't show the code.[/QUOTE]
What I have given you is the "run command". What others do is create their own.the task bar is a sealed class. If you read the code you have every ething that you need to create a run command that would run every thing you want, even api commands that windows already uses. (notepad,cmd, whatever)

[QUOTE=ashishkumar008;1449828]my brother,
we can not write like this
[ICODE]xxxxxx.URL=Properties.Resources.XXXXX[/ICODE]

Please bro try to understand my problem.
but you are trying to solve my problem, so thank's for your help and help again plzzzzz[/QUOTE]
OK get rid of the WMPlib. Its not needed, instead once you have the file added as a resource( "add existing Item" in your solution explorer) then add this code to a button event or your form load event.

[CODE]
Dim process As System.Diagnostics.Process
process = New Process(Me.GetType().Assembly.GetManifestResourceStream _
("ApplicationNamespace.SoundFile.mp3")
[/CODE]

WMPlib is used to create a Windows media player that will play files in the same directory as the app or as a movie player for media on the web (hence the .URL) It requires that the media be fed via URL link and only in a link. The code that I gave you earlier is also a good replacement for it as it does Not need the URL and will also implement the application resource information. [URL="

[QUOTE=dougancil;1449758]adapter.SelectCommand = _CMD[/QUOTE]

try doing this to overwrite the issue.

[CODE]
adapter.SelectCommand = New SqlCommand(_sql, connection)
[/CODE]

comment out the other lines on this post #11 ( line #50 in your program)
Your program for some reason did not see the _CMD as a active item and returned a null in its place. Force the command to see your connection and hopefully this time it will work.

[QUOTE=dougancil;1449752]I have removed it and still get the same error.[/QUOTE]
What exactly is the line 52 on your program that is referenced?

[QUOTE=dougancil;1449701]Zinnqu

Here is my code:

[code]
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles exceptionsButton.Click
Dim connection As System.Data.SqlClient.SqlConnection
Dim connectionString As String = "Initial Catalog=mdr;Data Source=xxxxx;uid=xxxxx;password=xxxxx"
Dim ds As New DataSet
Dim sql As String = "SELECT [Exceptions].Employeenumber,[Exceptions].exceptiondate, [Exceptions].starttime, [exceptions].endtime, [Exceptions].code, datediff(minute, starttime, endtime) as duration INTO scratchpad3" &
" FROM Employees INNER JOIN Exceptions ON [Exceptions].EmployeeNumber = [Exceptions].Employeenumber" &
" where [Exceptions].exceptiondate between @payperiodstartdate and @payperiodenddate" &

" GROUP BY [Exceptions].Employeenumber, [Exceptions].Exceptiondate, [Exceptions].starttime, [exceptions].endtime," & _
" [Exceptions].code, [Exceptions].exceptiondate"
connection = New SqlConnection(connectionString)
Dim _CMD As SqlCommand = New SqlCommand(_sql, connection)
Dim adapter As System.Data.SqlClient.SqlDataAdapter = Nothing
adapter.SelectCommand = _CMD
_CMD.Parameters.Add(New SqlClient.SqlParameter("@payperiodstartdate", payperiodstartdate))
_CMD.Parameters.Add(New SqlClient.SqlParameter("@payperiodenddate", payperiodenddate))
Try
adapter.Fill(ds)
If (ds Is Nothing) Then
'it's empty
MsgBox("There was no data for this time period, press Ok to continue", "No Data")
connection.Close()
Exceptions.Hide()
Else
'it exists and there are rows
adapter.Fill(ds)
connection.Close()
End If

    Catch ex As Exception
        MessageBox.Show(ex.ToString)
        connection.Close()
    End Try
    Exceptions.Show()
End Sub

[/code]

and when I run it now, debug stops in line 52 and tells me that NullReferenceException was unhandled.[/QUOTE]

remove the " = Nothing" since you moved it. That was my error. I apologize if that was unclear in the last post.

[QUOTE=dougancil;1449663]Zinnqu,

I have changed my code and on line 12 (of your code) intellisense tells me:

Variable adapter before it has been assigned a value. A null reference could result at runtime.[/QUOTE]

Go ahead, like this;

[CODE]
Dim adapter As System.Data.SqlClient.SqlDataAdapter = nothing
[/CODE]

That is a warning and not an error. You could also move the declaration. that would look something like this:

[CODE]

Dim _CMD as SqlCommand = New SqlCommand(_sql, connection)
Dim adapter As System.Data.SqlClient.SqlDataAdapter
adapter.SelectCommand = _CMD
[/CODE]

[QUOTE=ashishkumar008;1449386]Sorry! friend.
But i am [COLOR="red"]not using SoundPlayer[/COLOR].
I am using WindowMediaPlayer Control which have only URL property to play sound file.
Also i am [COLOR="red"]not using swf control[/COLOR], i am using WebBrowser Control to play .swf (flash file). It has also URL property or we can use startup path.

plzzzzz help me ....Read my question.[/QUOTE]

You missed the point of my response its not what you are using rather that getting to any resource that is in your project is located as Properties.Resources.XXXXXX

Change the thread.sleep count to a smaller number, decreasing the number of visible ticks. The sleep command causes a pause effect in the code decreasing this will shorten the pause.

[CODE]
using System.Media;

SoundPlayer m_MySound = new SoundPlayer(Properties.Resources.YourSoundFile);

//invoke as this

m_MySound.Play();
[/CODE]

as far as the swf control use the same method Properties.Resources.whatever

see this [URL="

Useful Thanks!

[QUOTE=dougancil;1448949]Thank you. So I modified my code with your code and now I'm getting a sqlexception error that I must declare the value for @payperiodstartdate on line 59 of my code. Which is this line:

What am I not seeing?[/QUOTE]

OK Final Code that you should just paste..... This will catch all exemptions and errors. Sorry for the confusion.

[CODE]
Dim adapter As System.Data.SqlClient.SqlDataAdapter
Dim connection As System.Data.SqlClient.SqlConnection
Dim connectionString As String = "Initial Catalog=mdr;Data Source=xxxxx;uid=xxxxx;password=xxxxx"
Dim ds As New DataSet
Dim sql as String = "SELECT [Exceptions].Employeenumber,[Exceptions].exceptiondate, [Exceptions].starttime, [exceptions].endtime, [Exceptions].code, datediff(minute, starttime, endtime) as duration INTO scratchpad3" &
" FROM Employees INNER JOIN Exceptions ON [Exceptions].EmployeeNumber = [Exceptions].Employeenumber" &
" where [Exceptions].exceptiondate between @payperiodstartdate and @payperiodenddate" &

" GROUP BY [Exceptions].Employeenumber, [Exceptions].Exceptiondate, [Exceptions].starttime, [exceptions].endtime," & _
" [Exceptions].code, [Exceptions].exceptiondate"
connection = New SqlConnection(connectionString)
Dim _CMD as SqlCommand = New SqlCommand(_sql, connection)
adapter.SelectCommand = _CMD
_CMD.Parameters.Add(New SqlClient.SqlParameter("@payperiodstartdate", payperiodstartdate))
_CMD.Parameters.Add(New SqlClient.SqlParameter("@payperiodenddate", payperiodenddate))
Try
adapter.Fill(ds)
If (ds Is Nothing) Or (ds.Rows.Count =0 ) Then
'it's empty
MsgBox("There was no data for this time period, press Ok to continue", "No Data")
connection.Close()
Form2.Hide()
Else
'it exists and there are rows
adapter.Fill(ds)
connection.Close()
End if

Catch ex As Exception
MessageBox.Show(ex.ToString)
connection.Close()
End Try
[/CODE]

If this helps please close the thread and vote.

[QUOTE=dougancil;1448895]Thank you for that fix. So then what's the best way to have an pop up window stating that there is no data in form2, if there is no data? I'd just like the window to say something like, "There was no data for this time period, press Ok to continue" and that would close the form2 window and also the pop up window (of course) ... I know how to close the windows but I don't quite know how to provide the user with that error in a pop up.[/QUOTE]

make this to the try section and this will do everything

[CODE]
Try
connection.Open()
adapter = New SqlDataAdapter("SELECT [Exceptions].Employeenumber,[Exceptions].exceptiondate, [Exceptions].starttime, [exceptions].endtime, [Exceptions].code, datediff(minute, starttime, endtime) as duration INTO scratchpad3" &
" FROM Employees INNER JOIN Exceptions ON [Exceptions].EmployeeNumber = [Exceptions].Employeenumber" &

" where [Exceptions].exceptiondate between @payperiodstartdate and @payperiodenddate" &
" GROUP BY [Exceptions].Employeenumber, [Exceptions].Exceptiondate, [Exceptions].starttime, [exceptions].endtime," &

" [Exceptions].code, [Exceptions].exceptiondate", connection)
adapter.Fill(ds)
If (ds Is Nothing) Or (ds.Rows.Count =0 ) Then
'it's empty
MsgBox("There was no data for this time period, press Ok to continue", "No Data")
connection.Close()
Form2.Hide()
Else
'it exists and there are rows
adapter.Fill(ds)
connection.Close()
End if

Catch ex As Exception
MessageBox.Show(ex.ToString)
connection.Close()
End Try
[/CODE]

[QUOTE=dougancil;1448833]What about the other error for the datagridcellcontentclick event error? I fixed the code for the rest.When the Exceptions window (form 2) opens, I'm still not seeing any data. Actually there's no data for this time period in my query so that brings me to the point of presenting a pop up to the user stating that there is no data for this time period ... what would be the best way to present that?[/QUOTE]

Sorry, I read it but forgot to address it.
Add this to the top of your form, just under the class name
[CODE]
Protected WithEvents DataGridView1 as DataGridView
[/CODE]

[QUOTE=dougancil;1448760]zinnqu,

What about this as a module?

[code]
Module Module1
Public payperiodstartdate As Date
Public payperiodenddate As Date
End Module
[/code]

What would be the benefit of creating a class as opposed to what I have done? Is your code more concise or more efficient than mine? I'm trying to write the best code that I can so when my project is done I won't have to go back later and over write my code.[/QUOTE]

Keep it your way as it is simple to remember. I uses classes in methods only to segregate data stores. Meaning that if I have more data for other parts of a program, I would separate them for their need. ie mydata for data myaddr for a ip address or physical. Its more of a personal preference than anything. Experiment and see what works best for you.

For the Second part, you need to copy exactly what i gave you earlier for the connection

line 13 is the error. the connection needs to look like this:
[CODE]
Dim adapter As System.Data.SqlClient.SqlDataAdapter
Dim connetionString As String = "Initial Catalog=mdr;Data Source=xxxxx;uid=xxxxx;password=xxxxx"
Dim ds As New DataSet
connection = New SqlConnection(connetionString)

    Try  
            connection.Open()
            adapter = New SqlDataAdapter("SELECT [Exceptions].Employeenumber,[Exceptions].exceptiondate, [Exceptions].starttime, [exceptions].endtime, [Exceptions].code, datediff(minute, starttime, endtime)  as duration INTO scratchpad3" & _
      " FROM Employees INNER JOIN Exceptions ON [Exceptions].EmployeeNumber = [Exceptions].Employeenumber" & _
      " where [Exceptions].exceptiondate between @payperiodstartdate and @payperiodenddate" & _
      " GROUP BY [Exceptions].Employeenumber, [Exceptions].Exceptiondate, [Exceptions].starttime, [exceptions].endtime," & _
      " [Exceptions].code, [Exceptions].exceptiondate", connection)
            adapter.Fill(ds)
            connection.Close()
    Catch ex ...

add this to the very top of your project
[CODE]Imports Excel = Microsoft.Office.Interop.Excel[/CODE]

make sure Microsoft Excel 12.0 Library Object is referenced in your project under
Project -> add reference

Tested and proven data passing method as follows, form one and two listed:

[CODE]
Public Class Form1

Sub test() 'sub to set data
    Form2.global1 = "test" 'pass data to new form
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    test() ' run the sub to set
    Form2.Show() ' show the new form

End Sub

End Class

Public Class Form2
Public global1 As String 'Global var that the program sees
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Label1.Text = global1 'set label with new values.
End Sub
End Class
[/CODE]

Note that Both classes are global

calling the Run command in windows is not really on option in vb.net how ever you can call any exe via System.Diagnostics.Process()

[CODE]
dim proc as new system.diagnostic.process()
dim x as integer

'assign a button so that you can click and a inputbox will prompt and you can try to type:
'notepad,cmd,calc to prove
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
x = inputbox("run exe","run")
proc = process.start(x)
[/CODE]

Form2 should be whatever you named your second form, and the same with the third. The forms need to be public as well. Here is a modified version of the code that will handle the errors and allow the fill. I am not sure what handles your query, if its a variable or something else then replace the comment in quotes with the appropriate information.

[code]
Public Class Exceptions

Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Dim ConnectionString as String = "Initial Catalog=mdr;Data Source=xxxxx;uid=xxxxx;password=xxxxx"
    Dim connection As System.Data.SqlClient.SqlConnection
    Dim adapter As System.Data.SqlClient.SqlDataAdapter
    Dim connetionString As String
    Dim ds As New DataSet
    connection = New SqlConnection(connetionString)

    Try  
            connection.Open()
            adapter = New SqlDataAdapter("Your SQL Statement Here", connection)
            adapter.Fill(ds)
            connection.Close()
    Catch ex As Exception
        MessageBox.Show(ex.ToString)
        connection.Close()
    End Try
End Sub

Private Sub DataGridView1_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    ExceptionEdit.Show()
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
    Main.payrollButton.Enabled = True
    Main.exceptionsButton.Enabled = False
    Me.Close()
End Sub

End Class
[/code]

The other way of handling data is to create a module that will hold the data your passing. This way the module is global and so is the data. This way you can pass the information from form to form without "FormX is not declared" Create the module and name your class. Add your global vars that you set in them for the program and ...

[QUOTE=dougancil;1448042]Zinnqu,

I think I can just pass the data from form1 to form2. I'm using stored procedures to run the rest of my queries, but those aren't happening until later. So I'm assuming that I can do the same code for form3 (if I have one) as well? Lastly, as you can see I'm executing a second sql query later in my form that the results I want to populate in a datagridview on form2. How would I go about doing that?

So this portion
[code]
Private Sub Button2Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles exceptionsButton.Click
Dim sql As String = "SELECT [Exceptions].Employeenumber,[Exceptions].exceptiondate, [Exceptions].starttime, [exceptions].endtime, [Exceptions].code, datediff(minute, starttime, endtime) as duration INTO scratchpad3" &

" FROM Employees INNER JOIN Exceptions ON [Exceptions].EmployeeNumber = [Exceptions].Employeenumber" &
" where [Exceptions].exceptiondate between @payperiodstartdate and @payperiodenddate" &

" GROUP BY [Exceptions].Employeenumber, [Exceptions].Exceptiondate, [Exceptions].starttime, [exceptions].endtime," & _
" [Exceptions].code, [Exceptions].exceptiondate"
Dim oCmd As System.Data.SqlClient.SqlCommand
Dim oDr As System.Data.SqlClient.SqlDataReader
oCmd = New System.Data.SqlClient.SqlCommand
Try
With oCmd
.Connection = New System.Data.SqlClient.SqlConnection("Initial Catalog=mdr;Data Source=xxxxx;uid=xxxxx;password=xxxxx")
.Connection.Open()
.CommandType = CommandType.Text
.CommandText = sql
.Parameters.AddWithValue("@payperiodstartdate", payPeriodStartDate)
.Parameters.AddWithValue("@payperiodenddate", payPeriodEndDate)
oDr = .ExecuteReader()
End With
oDr.Close()
oCmd.Connection.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
oCmd.Connection.Close()
End Try
Exceptions.Show()
End Sub
[/code]

needs to present data in that range back to end users who can then edit that data.[/QUOTE]

For the first question: Yes you can pass data in the same method pushing data to the other form via Form3.GlobalVar. The only thing that you need to make sure of is ...

[CODE]
ds.Tables(0).Rows(0).Item("LVLStat") = Me.txtUpdate.Text
[/CODE]

is the problem, you told it to update only this record. What you need to use is this to update your selected record

[CODE]
ds.SelectedRows.Item(0) = Me.txtUpdate.Text
[/CODE]

Do you want to pass the data from form to form? Or would you rather "INSERT" the data then pull the new data from the SQL database?

This is a consideration that needs to be used in the planning of your program. One way means you declare a global var that is on both forms which is done like this

[CODE]
'from form one
payPeriodStartDate = oDr.GetDateTime(1)
payPeriodEndDate = payPeriodStartDate.AddDays(7)
Form2.payPeriodStartDate = payPeriodStartDate
Form2.payPeriodEndDate = payPeriodEndDate
[/CODE]

The other requires a new table or columns added to you existing table so you can "insert" the values then "Select" the information on the second.

if that is the case then you need to look at [URL="