Oxiegen 88 Basically an Occasional Poster Featured Poster

First create a crystal report and design it in the way you like.
Then add these lines of code for whatever event you like to use for generating the report.
Assuming that DT_Data can be cast as DataTable.

Dim crp As New CrystalReport1
crp.SetDataSource(DirectCast(DT_Data, DataTable))
Oxiegen 88 Basically an Occasional Poster Featured Poster

This line:
mySqlCommand = New SqlCommand("Select sno from cmtable,mysqlconnection")
Move the quotation mark into this:
mySqlCommand = New SqlCommand("Select sno from cmtable", mySqlConnection)

Oxiegen 88 Basically an Occasional Poster Featured Poster

Ok. From the beginning.
From populating your combobox, selecting table and reading into DataGridView.
This assumes that the database type is an MS SQL server.

Imports System.Data.SqlClient

'''Read table names from database
Private Sub ReadTables()
   Dim con As New SqlConnection("<connectionstring>")
   Dim com As SqlCommand = Nothing
   Dim dr As SqlDataReader = Nothing
   Dim schemaTable As DataTable

   Try
      combobox1.Items.Clear()

      con.Open()

      'Get table and view names
      com = New SqlCommand("SELECT DISTINCT name FROM sysobjects WHERE xtype='U'", con)
      dr = com.ExecuteReader(CommandBehavior.CloseConnection)
      If dr.HasRows Then
         While dr.Read
            combobox1.Items.Add(dr.item("name"))
         End While
      End If
      dr.Close()
   Catch ex As Exception
      If con.State = ConnectionState.Open Then
         con.Close()
      End If
   End Try
End Sub

'''Select table from combobox
Private Sub combobox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles combobox1.SelectedIndexChanged
   If combobox.SelectedIndex > -1 Then
      ReadFromDataBase(combobox.SelectedItem)
   End If
End Sub

'''Read from database and display in DataGridView
Private Sub ReadFromDataBase(table As String)
   Dim con As New SqlConnection("<connectionstring>")
   Dim com As SqlCommand = Nothing
   Dim da As SqlDataAdapter = Nothing

   Dim table As DataTable

   Try
      con.Open()
      com = New SqlCommand("SELECT * FROM " & table, con)
      da = New SqlDataAdapter(com)
      da.Fill(table)
      con.Close()

      datagridview.DataSource = Nothing
      datagridview.DataSource = table
   Catch ex As Exception
      If con.State = ConnectionState.Open Then
         con.Close()
      End If
   End Try
End Sub
Oxiegen 88 Basically an Occasional Poster Featured Poster

SQL has a function called SUM(), which does exactly what the name implies.
So, in your SQL string you can do this:

INSERT INTO dbo.RetailerBalance([BoothID], [GrandTotal], [Accumulated]) VALUES ('" & Form1.txtBoothID.Text & "','" & frmCurrentBalance.lblBalance.Text & "',SUM([GrandTotal]))
Oxiegen 88 Basically an Occasional Poster Featured Poster

Basically, all you have to do is create a shortcut on each users desktop, pointing to the executable of your program.
Ex: \\server\share\yourprogram.exe, or <network driveletter>:\yourprogram.exe

For more information on how to deal with database concurrency issues, you might wanna google with these keywords: vb.net multiple users concurrency

Oxiegen 88 Basically an Occasional Poster Featured Poster

You should look into the uses of StreamReader and StreamWriter.

'Reading files
Private Sub ReadFile(Filename As String)
   Dim stream As New IO.FileStream(Filename, IO.FileMove.Open)
   Dim sr As New IO.StreamReader(stream)
   Dim line As String = ""

   While sr.Peek <> -1  'Read until EOF
      line = sr.ReadLine
   End While
   sr.Close()
   stream.Close()
End Sub

'Writing to files
Private Sub WriteFile(Filename As String)
   Dim stream As New IO.FileStream(Filename, IO.FileMode.Create)
   Dim sw As New IO.StreamWriter(stream)

   sw.WriteLine("Here's some text to write on a line") 'Automatic linebreak in file
   sw.Flush()
   sw.Close
   stream.Close()
End Sub
Simran Kaur commented: was helpful +1
Oxiegen 88 Basically an Occasional Poster Featured Poster

If you copy the contents of the DataGridView into an AdoDb recordset, then you can use this method to accomplish your goal.
http://www.tek-tips.com/faqs.cfm?fid=6739

Oxiegen 88 Basically an Occasional Poster Featured Poster

The SQL command is SQLCommand = "SELECT * FROM Teams"

Which is what the help file suggested using, however, I find it strange that you'd use the select command to add. I'd have though INSERT would have been the correct line, but I'm not sure how to formulate the line.

That's how the commandbuilder works.
You insert the SELECT query and a DataAdapter, and it spits out the queries for SELECT, INSERT, UPDATE and DELETE.
Very cool, if I may say so. :)

Oxiegen 88 Basically an Occasional Poster Featured Poster

You can try to programmatically change the template to use for that column, after the databinding, while still having that Bit column.

If dtfinal.Rows.Count <> 0 Then
   dg4.DataSource = dtfinal
   Dim chkBox As New DataGridViewCheckBoxColumn(False)
   dg4.Columns(0).CellTemplate = chkBox.CellTemplate
Else
   dg4.DataSource = ""
End If
Oxiegen 88 Basically an Occasional Poster Featured Poster

Can you confirm that the InsertCommand property of DataDataSet2 indeed contains the SQL query for inserting new records?
If I were to guess, then that may be where the problem lies now.

Oxiegen 88 Basically an Occasional Poster Featured Poster

Ok. Then you can try to move the call to AcceptChanges down a notch.
All DataSet, DataTables and DataRows have that method. DataDataSet.Tables("Teams").AcceptChanges()

Oxiegen 88 Basically an Occasional Poster Featured Poster

Ok. Well then it depends on which dataset you're using as a permanent dataset.
DataDataSet or DataDataSet2?

Oxiegen 88 Basically an Occasional Poster Featured Poster

Add one single line of code just before you call the Update() method on the second dataset.

DataDataSet.Tables("Teams").Rows.Add(TeamInfo)
''' Add this line, this will commit any changes made to the dataset since it was loaded
DataDataSet.AcceptChanges()
'''
DataDataSet2.Update(DataDataSet, "Teams")
Oxiegen 88 Basically an Occasional Poster Featured Poster

Well, if you're not setting the value somewhere else, then the value of Me.pass is what you just set it to in your codesnippet.

I have no idea as to why you have an ampersand in the first ToDouble method, especially considering that the ampersand is a string concatinator, which would make that value 43.
So the value of Me.pass would be this:
((43 - 4) + (2 * 1)) / 2 = (39 + 2) / 2 = 41 / 2 = 20.5

Oxiegen 88 Basically an Occasional Poster Featured Poster

Thank you.
Now I know. :)

Oxiegen 88 Basically an Occasional Poster Featured Poster

Let's say, for instance, that you posted an answer to a question. Only to realize a few seconds later that your answer is not correct.

How do I delete that post, or do I just add a comment for the moderators, asking them to remove it for me?

Oxiegen 88 Basically an Occasional Poster Featured Poster

You're welcome. :)
Please mark this thread as solved if your problem is fixed.

Oxiegen 88 Basically an Occasional Poster Featured Poster

I suggest this project: http://www.codeproject.com/KB/audio-video/SoundClass.aspx.

You can always find an answer if you google it.

Oxiegen 88 Basically an Occasional Poster Featured Poster

The Left property is the horizontal position of the panel within it's parent container, there is no Right property.
If you need to move the panel from left to right, then you have to change the value of Left.

Panel122.Left = 0, means that the panel is at it's left-most position.
Panel122.Left = parent.Width, means that the panel is at it's right-most position.

Oxiegen 88 Basically an Occasional Poster Featured Poster

Than LCASE() is the way to go.

Oxiegen 88 Basically an Occasional Poster Featured Poster

That is one of the most undescriptive error messages I've ever seen.

But you can probably eliminate the problem if you change LOWER() to LCASE(), , but because I don't know if you are using SQL Express or MS Access as a database, you just have to try your luck with the trial-and-error approach.

Also, I surely hope that you just didn't copied my snippet and thought it would work.
I have no idea how you store a customers name, either in one single column or in two.

Oxiegen 88 Basically an Occasional Poster Featured Poster

If the customers full name is stored in one single string, then what you have is perfectly fine.
However, you might wanna consider performing the check in all lower case.
Like so:

Dim sqlQRY As String = "SELECT COUNT(*) AS numRows FROM CustomerInformation WHERE LOWER(CustomerName) = '" & TextBox1.Text.ToLower() & "'"

But if name and surname are separate entities, then you need to do this:

Dim sqlQRY As String = "SELECT COUNT(*) AS numRows FROM CustomerInformation WHERE LOWER(CustomerName) = '" & TextBox1.Text.ToLower() & "' AND LOWER(CustomerSurname) = '" & SurnameTextBox.Text.ToLower() & "'"
Oxiegen 88 Basically an Occasional Poster Featured Poster

You probably marked this thread as solved by mistake.
If that is so, then might I suggest a small change in the first snippet.
On line 7, do the following change:

'Your code
.strWhere = "{PlotNo.Hiring} = """ & TextBox9.Text & """"

'Remove the soft brackets and change it to this
.strWhere = "PlotNo.Hiring = '" & TextBox9.Text & "'"
Oxiegen 88 Basically an Occasional Poster Featured Poster

I'm not surprised.

'Change this line
If value1 = r2 Then
' to this
If value1 = value2 Then
Oxiegen 88 Basically an Occasional Poster Featured Poster

I suggest that you follow the coding in the second snippet I gave in my first respons to you.
It states, with the name of your class:

Dim clsMethods As Cruce
If radiobutton1.checked = true then
   clsMethods = New Cruce("method1")
ElseIf radiobutton2.checked = true then
   clsMethods = New Cruce("method2")
Else
   clsMethods = New Cruce("method3")
End If

clsMethods.Method(pob.ind(i), pob.ind(i + 1))
Oxiegen 88 Basically an Occasional Poster Featured Poster

According to the snippet you just posted, I'd have to say yes.
Change line 1 to simply say: Dim rnd As New Random().
And keep lines 2 and 3.

Oxiegen 88 Basically an Occasional Poster Featured Poster

Force a save just before you apply the protection.
I'm just providing suggestions, not solutions, because I don't know how you access the excel file.

'' --- Save the file here --- ''

'Protect all sheets
Dim WSheet As Worksheet
    For Each WSheet In Worksheets
        If WSheet.ProtectContents = False Then
            WSheet.Protect Password:="password"
        End If
    Next WSheet
Oxiegen 88 Basically an Occasional Poster Featured Poster

Obviously.
But if they weren't. How would they get there?

In order to speed this up a bit.
The answer to your question is Yes, you will need to have some kind of entry control, like a textbox.
One textbox where you enter what to search for, and one textbox where you enter the replacement value.

Oxiegen 88 Basically an Occasional Poster Featured Poster

Gee, I don't know.
If you, somewhere, on the form need to select a value to search for and, somewhere else, a value to replace it.
Consider how you would go about doing it.

Take your code snippet for example.
How would you get the value &H12CC0 if you didn't hard-code it?
Same goes for the line bw.write("1"), where would that value come from?

Oxiegen 88 Basically an Occasional Poster Featured Poster

Unfortunately, using heavy graphics and in such sizes tends to slow things down a bit.
I have a friend who did the same thing in her application. And it was sluggish even on my, high-end, computer.

For the large, I'm assuming, background image I recommend that you pick a solid color background and use pictureboxes for the details.
Those pictureboxes can be moved on the z-axle so that they appear behind all other controls. Right-click on the picturebox and select "Send to Back".

I'm not entirely educated regarding flash animations, but I think others would agree with me that they too consume a fistful of CPU power.
So you should keep those at a minimum as well.

When all is said and done, your application may look cool as hell.
But what's the point when you can't run it properly?

Oxiegen 88 Basically an Occasional Poster Featured Poster

Ah! Now I see what you're doing.
What would happen if you save the excel document before doing the protection thing?

Oxiegen 88 Basically an Occasional Poster Featured Poster

Change it to this:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click      
   If Gcoinspoint <= 0 Then
      'Here you can choose to reset Gcoinspoints to 50
   End If
   Gcoinspoint -= 5
Oxiegen 88 Basically an Occasional Poster Featured Poster

Ok. Try and see if this works.
If I'm right, it will replace all occurences of the given "find" string within the file.

Private Sub FindAndReplace(ByVal FileName As String, ByVal find As String, ByVal replace As String)
        Dim fs As IO.FileStream
        fs = New IO.FileStream(FileName, IO.FileMode.OpenOrCreate)

        Dim buffer() As Byte
        Using br As New IO.BinaryReader(fs)
            buffer = br.ReadBytes(fs.Length)
        End Using
        fs.Close()

        fs = New IO.FileStream(FileName, IO.FileMode.Create)
        Dim text As String = System.Text.Encoding.UTF8.GetString(buffer).Replace(find, replace)
        Using bw As New IO.BinaryWriter(fs)
            buffer = System.Text.Encoding.UTF8.GetBytes(text)
            bw.Write(buffer)
        End Using

        MessageBox.Show("Finished", "", MessageBoxButtons.OK, MessageBoxIcon.Information)
    End Sub
Oxiegen 88 Basically an Occasional Poster Featured Poster

I understand.
Can you post your code for the search and replace?
Perhaps we can take a look and see what the problem is.

Oxiegen 88 Basically an Occasional Poster Featured Poster

Oops. Didn't look at the name of the poster. My bad. :)

You can create a structure outside the class and make it public.
Now it will be accessible from anywhere.

Public Structure individuo
   Dim x() As Double
   Dim fx As Double
End Structure
Public Structure poblacion
   Dim ind() As individuo
End Structure

Public Class Cruce
...
End Class
Oxiegen 88 Basically an Occasional Poster Featured Poster

What are the properties for the report file?

Check "Build Action", if it's set to Embedded Resource, then change that to None.
Check "Copy to Output Directory", if it's set to Do not copy, then change that to Copy always.

You need to make sure that the report file resides in the directory you are trying to load it from.

Oxiegen 88 Basically an Occasional Poster Featured Poster

Why do you add 45 to GcoinPoints every time you click the button, regardless if you win or lose?

This is three losing rounds:
First round: GcoinPoints = 45
Second round GcoinPoints = 90
Third round GcoinPoints = 135

That could be the reason for problem 1, that the score is increasing in large chunks.
For problem 3, try to limit the random generator to choose between a set number of integers, like 1-10.
That would probably increase the odds.

Dim rnd As New Random
Dim value1 As Integer = rnd.Next(1, 10)
Dim value2 As Integer = rnd.Next(1, 10)
Oxiegen 88 Basically an Occasional Poster Featured Poster

On line 8, do this: cryRpt.Load(Application.StartupPath & "\Hir.rpt")

Oxiegen 88 Basically an Occasional Poster Featured Poster

Application.StartupPath points to the folder where your appliction is executed from.

For example, if you install your application to "C:\SomeKindOfApp\myapp.exe", then Application.StartupPath will point to "C:\SomeKindOfApp".

So, if the report you wish to load is on another disk, then Application.StartupPath won't work.
However, if the report file is located in the same folder as your executable, then Yes, Application.StartupPath will work perfectly.

Oxiegen 88 Basically an Occasional Poster Featured Poster

No, that is correct even in VB.NET.
That being said, if the object contains a Dispose method, then you should do myObj.Dispose() before assigning it to Nothing.

Oxiegen 88 Basically an Occasional Poster Featured Poster

Assuming that the error occurs on line 8, then the most likely cause is the path.
Is it correct?

Oxiegen 88 Basically an Occasional Poster Featured Poster

It doesn't matter if you log on the client computer as administrator or not.
Because it is the WEBSERVERS user account that needs access to the local computer.
Thus, if the user accounts IIS_IUSRS and/or ASPNET don't have write access to the local computer, then nothing will be copied.

I did some googling on this matter, and it seems like you need to do some javascripting to make this work.
Or, as another article states, ZIP the files and download that single file.

Oxiegen 88 Basically an Occasional Poster Featured Poster

I see.
But your original question was "Is it possible to assign a method to a variable?".
And the answer is No, which is why I gave you a solution, that you built your own solution on.

Now I'm asking you, does it work?
Is your problem solved?

Oxiegen 88 Basically an Occasional Poster Featured Poster

I see.
Well, if you want to load a database from another drive you will have to change that.
In other words, replace Application.StartupPath with a hardcoded path: D:\<path_to_database>\Payment.mdb

Oxiegen 88 Basically an Occasional Poster Featured Poster

Yes. You do that in the connection string.
Assuming that you're using an Access database, then the connection string might look something like this.
Notice the Data Source path.

Dim con As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\mydatabase.mdb;User Id=admin;Password=;")
Oxiegen 88 Basically an Occasional Poster Featured Poster

Ok. Three questions.
What does button1 open?
How far have you come yourself?
Have you tried searching for the solution, either here or on Google?

Oxiegen 88 Basically an Occasional Poster Featured Poster

I'll be around. :)

Oxiegen 88 Basically an Occasional Poster Featured Poster

What happens if you reset the protection after you update the Excel sheet?

By looking at your code it seems like you fírst unlock the sheet, read from the MySql database and then lock the sheet again, without updating the sheet.
When do you do your update?

Oxiegen 88 Basically an Occasional Poster Featured Poster

This question should have been posted in the ASP.NET forum.

But to answer your question.
Add a module to your project by right-clicking your project and select Add->Module.
Put your function in there and make it Public instead of Private.
Voila! Now you can use your code from everywhere.

Oxiegen 88 Basically an Occasional Poster Featured Poster

You should examine the keyword BETWEEN for SQL queries.
SELECT * FROM table WHERE Timing BETWEEN '#23/07/2010#' AND '#02/08/2010#'

And if you are using the JET driver when connecting to your Access database, you can try formatting the date as YYYY-MM-DD inside the query in order to avoid confusion.
You can always reformat it later for presentation.
SELECT * FROM table WHERE Timing BETWEEN '#2010-07-23#' AND '#2010-08-02#'