Begginnerdev 256 Junior Poster

We had to upgrade from 10.0 to 12.0 when we upgraded. We are doing some basic inserting/deleting from table and running some queries.

As far as provider, is it a connection string problem?

See here.

Begginnerdev 256 Junior Poster

Have you tried using the Me.Load event instead to see what happens?

Begginnerdev 256 Junior Poster

There are quite a few issues with 2000 > 2007, but with 2003 we only had a few missing controls some forms in an MDE application.

We lost small stuff like a drop-down calendar and a text box off of another form.

Here is a decent article you can read as well.

Begginnerdev 256 Junior Poster

Copy the files to a directory in the solution of your project.

Then include the directory with the publish.

When looking at the solution explorer, add a folder.

Once you have added and named the folder, right click and click add existing item.

Set the filter of the dialog to any file type, navigate to the items, and click them, and press add.

Begginnerdev 256 Junior Poster

The code:

Dim rowcnt As Integer = (dtOrder.Rows.Count - 1)
For x = 0 To rowcnt
    If IsNumeric((dtOrder.Rows(x)(3).ToString)) Then
    val = CInt(dtOrder.Rows(x)(3).ToString)
        With fractColumn
            .ColumnName = "xttl"
            .Expression = ((dlgNewTop.Dec2Frac(val, 2)))
        End With
    End If  
Next

 With dtOrder.Columns
     .Add(fractColumn)
 End With

Will only add the last because that is the only row you are telling it to add.

This code is outside the for:

 With dtOrder.Columns
     .Add(fractColumn)
 End With

Therefore, the only value added would be the last value it sees. (The value of the column from the last row of dtOrders)

Try This instead:

For x = 0 to dtOrder.Rows.Count - 1
 If IsNumeric((dtOrder.Rows(x)(3).ToString)) Then
    val = CInt(dtOrder.Rows(x)(3).ToString)
        With fractColumn
            .ColumnName = "xttl"
            .Expression = ((dlgNewTop.Dec2Frac(val, 2)))
        End With
    End If 

    With dtOrder.Columns
     .Add(fractColumn)
    End With
Next
Begginnerdev 256 Junior Poster

Your select statement for your datagridview can be edited to order by the column chosen.

For example:

"SELECT * FROM Table ORDER BY Column4 ASC"

Will sort data by column for ascending.

For decending just do the opposite:

"SELECT * FROM Table ORDER BY Column4 DESC"
Begginnerdev 256 Junior Poster

Change this:

ds.Tables("FamilieNummer")

To This:

ds.Tables("Max")

You are filling a table called "Max" but searching for a table called FamilieNummer.
Remember that the data set is in memory, not in database.

I am sorry to hear about health problems. I hope everything is okay!

Begginnerdev 256 Junior Poster

Not quite sure what you plan to acheive with that syntax.

If you are trying to format the output, read this.

Begginnerdev 256 Junior Poster

If you are only wanting to increase the width (on the left) you will have to reposition the panel on resize to give the user the illusion it is only increasing the width on the left.

For exmaple:

Do While Panel1.Width < 730
    Panel1>Width += 1
    Panel1.Location = New Point(Panel1.Location.X - 1, Panel1>Location.Y)
Loop
Begginnerdev 256 Junior Poster

When you say sliding the panel, do you mean in the parent control or the scroll bar of the panel?

Begginnerdev 256 Junior Poster

Are both clients connected to the same database, or are you both working on two different applications?

Begginnerdev 256 Junior Poster

You can check per column basis:

For example:

  Dim Found As Boolean
  For Each r As DataRow In dt.Rows
      Found = False
      For i = 0 To dt.Columns.Count
          If r(i) = "ThisValue" Then
              Found = True
              Exit For
          End If
      Next
      If Found Then Exit For
  Next

Also, I have posted another solution on your other post.

Begginnerdev 256 Junior Poster

A quick google search returned a few things.

One being permissions the other being this.

Begginnerdev 256 Junior Poster

The correct syntax would be:

"SELECT SEGDATA.AdminNo, PapersList.PaperNo FROM SEGDATA,PapersList WHERE SEGDATA.ModuleCode = PapersList.Module1"

This will return all of the records that match.

This will be in the format you want.

You can also add the DISTINCT clause for filtering duplicates.

As for the PapersList Table, you could try using one ModuleCode column with MAX length.

Then you could have more than 9 codes per paper number.

For example

|ModuleCodes|
|EG1003;EG1001;EG1201;EG1092|

Then you could parse the field for the value by splitting on ";" or just tell SQL to get the value with the LIKE Clause.

Begginnerdev 256 Junior Poster

It would depend on the database you are using. (Looks like Access)

Data.SQLClient is microsoft's library for Access and SQLServer.

You can use OLEDB or one of numereous others.

Begginnerdev 256 Junior Poster

Something like:

"SELECT MAX(ColumnName) As MaxValue From Table "

Then pass that query to a datatable and pull into a textbox

Dim da As New SQLDataAdapter("SELECT MAX(ColumnName) As MaxValue From Table ",MySQLConnection)
Dim ds As New DataSet

da.fill(ds,"Max")

If Not IsNothing(ds.Tables("Max")) And ds.Tables("Max").Rows.Count > 0 Then
    TextBox1.Text = ds.Tables("Max").Rows(0)("MaxValue")
End If
Begginnerdev 256 Junior Poster

It would be easier to do a SELECT with an inner join.

Something like:

"SELECT SEGDATA.AdminNo, Paperslist.PaperNo InnerJoin SEGDATA on PapersList.Module1 = SEGDATA.ModuleCode"

But my SQL is a little lacking

I hope this points you in the right direction.

Reverend Jim commented: Nothing lacking there. +12
Begginnerdev 256 Junior Poster

You can parse the last six characters of the string to get the last six.

Just parse the selected item, or parse when the item is being inserted into the combobox.

For example:

Private Sub LoadData(ByVal lstString As List(Of String))
    Try
        For Each s As String In lstString
            ComboBox1.Items.Add(s)

            'You can parse here for reference before the selected index change.
            'dicLastSix is a Dictionary(Of String, String)
            'This will give you a reference before the item is selected in the cobobox/
             dicLastSix.Add(s, GetLastSix(s))
        Next
    Catch ex As Exception
        MsgBox(ex.ToString)
    End Try
End Sub

Private Function GetLastSix(ByVal str As String) As String
    'Modify this function to return what you want in the case of an exception being thrown.
    Try
        If str.Length - 7 > 0 Then '0 index have to subtract 7 for 6 items
            Return str.IndexOf(str, str.Length - 7, str.Length - 1)
        Else
            Return str.IndexOf(str, 0, str.Length - 1)
        End If
    Catch ex As Exception
        MsgBox(ex.ToString)
        Return String.Empty
    End Try
End Function

Private Sub IndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles ComboBox1.SelectedIndexChanged
    Try
        'Geting the last 6 from caling the function
        If Not IsNothing(TryCast(sender, ComboBox)) Then
            Dim s As String = CStr(TryCast(sender, ComboBox).SelectedItem)
            MsgBox("Last Six: " & GetLastSix(s))
        End If
    Catch ex As Exception
        MsgBox(ex.ToString)
    End Try
End Sub
Begginnerdev 256 Junior Poster

Have you verified the logic of the select?

I see (1) AND (2) OR (3) OR (4)

If this statement gets qualified, you can have a maximum of 3 outcomes.

(1) and (2) are true
(3) is true
(4) is true

Is this correct?

Begginnerdev 256 Junior Poster

You will have to set the name of the button, or loop through the forms controls:

NT.Name="MyButton1"

Or

For Each m As MyButton in Me.Controls
    m.Dispose 'NOTE: m MUST INHERIT CONTROL
Next
Begginnerdev 256 Junior Poster

One question would be - What differs from test data to live data.

Does the data format change, or just values?

Begginnerdev 256 Junior Poster

Don't forget to mark as solved!

Begginnerdev 256 Junior Poster

One thing to take into consideration in packet loss /size of image.

If there is a large amount of packet loss between you and the site - the quality will suffer greatly.

If the size of your picturebox is smaller/larger than the original image there will be stretching or pinching. This causes pixelation.

Begginnerdev 256 Junior Poster

Not knowing =/= Laziness.

It is a good thing that you are willing to learn!

Begginnerdev 256 Junior Poster

You could take that string returned, split and parse it to what you need.

For example:

Private Function ParseIngredients(ByVal strIngredients As String) As Dictionary(Of String, Double)
    Try
        strIngredients = "(Water (20), Salt(30))" 'When passing the value in delete this, this is just for example.
        Dim dic As New Dictionary(Of String, Double)

        Dim lstIngredients As List(Of String) = strIngredients.Split(",").ToList()
        'lstIngredients(0) = "(Water (20)"
        'lstIngredients(1) = "Salt (30))"

        For Each s As String In lstIngredients

            Dim Key As String = String.Empty
            Dim Value As Double = 0.0
            s = s.Replace("(", "") 'Will return "Water 20)"
            s = s.Replace(")", "") 'Will return "Water 20"

            Key = s.Split(" ").ToList(0) ' Will return Water
            Value = Cdbl(s.Split(" ").ToList(1)) 'Will return 20.0 as Double
            'The key will be set to Water
            'The value will be set to 20

            'Add to dictionary
            dic.Add(Key, Value)
        Next

        Return dic
    Catch ex As Exception
        MsgBox(ex.ToString)
        Return New Dictionary(Of String, Double)
    End Try
End Function

Just pass in the ingredients string and accept the output dictionary.

Iterating through the dictionary can be done as follows:

For Each kvp As KeyValuePair(Of String,Double) In ParseIngredients(IngredientsStringHere)
    DeductFromTotal(kvp.Key,kvp.Value)
Next

I hope this helps!

ddanbe commented: Helpfull +14
Begginnerdev 256 Junior Poster

Place the code in a sub procedure and pass in the item type for the action:

Private Sub DeductFromTotal(ByVal sItemType As String,ByVal dblAmountToSubtract As Double)
    Try
        Dim da As New MySqlDataAdapter(New MySqlCommand("SELECT * FROM Inventory WHERE Item='" & Me.ComboBox1.Text & "'", New MySQLConnection("ConnectionStringHere")) 
        'You don't have to open the connection before using it in the adapter.'
        'The select gets the table structure.'

        Dim ds As New DataSet
        da.Fill(ds, "Inventory")
        If Not IsNothing(ds.Tables("Inventory")) And ds.Tables("Inventory").Rows.Count > 0 Then
            Dim dblCurrentAmount As Double = CDbl(ds.Tables("Inventory").Rows(0)("Amount")) - dblAmountToSubtract '(This dblAmountToSubtract is not declared, what should it be set to?)
            If dblCurrentAmount < 0 Then
                MsgBox("You have used more than what is in stock!" & vbCrLf & "This operation will not be completed", MsgBoxStyle.Exclamation, "ERROR!")
                GoTo DISPOSE
            ElseIf dblCurrentAmount = 0 Then
                MsgBox("You have depleted your stock for this item!" & vbCrLf & "Please restock this item!", MsgBoxStyle.Exclamation, "Oops!")
            End If

            ds.Tables("Inventory").Rows(0)("Amount") = dblCurrentAmount
            da.UpdateCommand = New MySQLCommandBuilder(da).GetUpdateCommand
            da.Update(ds, "Inventory")
            MsgBox("Item Updated!", MsgBoxStyle.Information, "Complete!")
        End If
DISPOSE:
            da = Nothing
            ds = Nothing
    Catch ex As Exception
        MsgBox(ex.ToString)
    End Try      
End Sub

Then call it from code (A button click would work)

Private Sub btnSalad_Click(sender As Object, e As EventArgs) Handles btnSalad.Click
    Try
        'Get list of ingredients from table
            For Each s As String In lstIngredients 'List(Of String)
                DeductFromTotal(s,Cdbl(txtIngredient1.Text))
            Next
    Catch ex As Exception
        MsgBox(ex.ToString)
    End Try
End Sub

This begs the question: How are you binding an ingredient list to the item type?

Are you doing something like this?

…
Begginnerdev 256 Junior Poster

Without using any control the only way would be to draw an image and place the image in the background of the form.

If you do not plan to use the Graphics library then your question has met a dead end. :(

Begginnerdev 256 Junior Poster

dblAmountToSubtract will be a variable declared as double that will hold the value to subtract from your total.

For Example:

Dim dblAmountToSubtract As Double = Cdbl(txtAmountUsed.Text)
'This pulls the amount from a text box on a form.

For the command, you can simply replace:

da.UpdateCommand = New OleDb.OleDbCommandBuilder(da).GetUpdateCommand

With

da.UpdateCommand = New MySQLCommandBuilder(da).GetUpdateCommand
Begginnerdev 256 Junior Poster

You will have to change the column names in the dr("column") with the correct column names.

Begginnerdev 256 Junior Poster

The select statment retreives the record from your database table.

For example:

Inventory
Item  | Amount
garlic,10.21
onion,50.13
water,200.23


"SELECT * FROM Inventory WHERE Item='garlic'" 'Would return garlic,10.21

As for the myConnection, you will need a connection to the database to retreive the data from the database.

In this case, my connection would look as follows:

Dim myConnection As New OleDBConnection("MyConnectionStringHere")

For connection strings, see this website.

I hope this clears things up for you!

savedlema commented: Thanks Begginerdev. Please check my reply. +0
Begginnerdev 256 Junior Poster

You will have to get the current value, subtract, then update to the newest value.

This is assuming your amount colum in as decimal value.

For Example:

       Try
            Dim da As New OleDbDataAdapter(New OleDbCommand("SELECT * FROM Inventory WHERE Item='" & sItemType & "'", myConnection))

            'The select gets the table structure.
            Dim ds As New DataSet

            da.Fill(ds, "Inventory")

            If Not IsNothing(ds.Tables("Inventory")) And ds.Tables("Inventory").Rows.Count > 0 Then
                Dim dblCurrentAmount As Double = CDbl(ds.Tables("Inventory").Rows(0)("Amount")) - dblAmountToSubtract

                If dblCurrentAmount < 0 Then
                    MsgBox("You have used more than what is in stock!" & vbCrLf & "This operation will not be completed", MsgBoxStyle.Exclamation, "ERROR!")
                    GoTo DISPOSE
                ElseIf dblCurrentAmount = 0 Then
                    MsgBox("You have depleted your stock for this item!" & vbCrLf & "Please restock this item!", MsgBoxStyle.Exclamation, "Oops!")
                End If

                ds.Tables("Inventory").Rows(0)("Amount") = dblCurrentAmount

                da.UpdateCommand = New OleDb.OleDbCommandBuilder(da).GetUpdateCommand
                da.Update(ds, "Inventory")

                MsgBox("Item Updated!", MsgBoxStyle.Information, "Complete!")
            End If
DISPOSE:
            da = Nothing
            ds = Nothing
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try 
Reverend Jim commented: Nice complete answer. +12
savedlema commented: Thanks Begginerdev. Please check my reply. +2
Begginnerdev 256 Junior Poster

Why not use a data adapter?

For example:

       Try
            Dim da As New OleDbDataAdapter(New OleDbCommand("SELECT * FROM Rooms WHERE 1=2", _
                                           New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source='C:\PATIENT_O\PATIENT_O\Patient-O.accdb'"))) 

                                           'The select gets the table structure.
            Dim ds As New DataSet

            da.Fill(ds, "Rooms")
            Dim dr As DataRow = ds.Tables("Rooms").Rows.Add()

            'Replace these names with the exact names you have.

            dr("[RoomID]") = IIf(String.IsNullOrEmpty(txtRoomID.Text), DBNull.Value, txtRoomID.Text)
            dr("[First Name]") = IIf(String.IsNullOrEmpty(txtroomFName.Text), DBNull.Value, txtroomFName.Text)
            dr("[Middle Name]") = IIf(String.IsNullOrEmpty(txtroomMName.Text), DBNull.Value, txtroomMName.Text)
            dr("[Last Name]") = IIf(String.IsNullOrEmpty(txtroomLName.Text), DBNull.Value, txtroomLName.Text)
            dr("[Room Type]") = IIf(String.IsNullOrEmpty(txtRoomType.Text), DBNull.Value, txtRoomType.Text)
            dr("[Amt/Day]") = IIf(String.IsNullOrEmpty(txtroomAmount.Text), DBNull.Value, txtroomAmount.Text)
            dr("[Comments]") = IIf(String.IsNullOrEmpty(txtroomComment.Text), DBNull.Value, txtroomComment.Text)

            da.InsertCommand = New OleDb.OleDbCommandBuilder(da).GetInsertCommand
            da.Update(ds, "Rooms")

            da = Nothing
            ds = Nothing
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try

My eye catches txtRoomComment.text.

If there is a ' character present in that field, you would have been terminating the sql statement.

DataAdapters protect against this.

Begginnerdev 256 Junior Poster

There a couple methods you can use:

PrintForm and PrintDocument

Printform sends an image of the active form to the printer. (Simple output)

PrintDocument sends the output to the printer, but you have to specify the output.

PrintDocument sounds like what you are wanting.

Begginnerdev 256 Junior Poster

There is a (very) old forum post on this exact topic.

The (possible) solution can be found here.

Begginnerdev 256 Junior Poster

I suspect a field length on one of your values you are inserting/updating.

For example:

Dim str As String = "Hello World"

If the length of str is greater than the size of the field (varchar or nvarchar) then you will truncate the data.

Begin by looking at all of the string fields that are being inserted/updated and check those first.

Begginnerdev 256 Junior Poster

The number on the end of each function represents the bit count, therefore, represents the maximum value that can be returned by that function ( as Integer )

Int16 - 16bit
Int32 - 32bit
Int64 - 64bit

As for the decimal places, the ToInt32 function returns an integer, which is a whole number. Therefore the decimal value will be rounded.

Begginnerdev 256 Junior Poster

You could place a timer on SplashScreen1, then do the following:

DIm ss1 As New SplashScreen1

ss1.ShowDialog() 'Will be a modal window and will not show Form2 Until it is closed.
ss1 = Nothing

Form2.Show()

Now, for the timer bit, in the SplashScreen_Load event place a timer.Start.

Private Sub Me_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
    Try
        Timer1.Start()
    Catch ex As Exception
        MsgBox(ex.ToString)
    End Try
End Sub

Now place the closing code in the timer.Tick method.

Private iCount As Integer = 0 'Must store value of timer tick.
Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As EventArgs) Handles Timer1.Tick
    iCount += 1
    If iCount = 5000 THen Me.Close
End Sub

This will wait as long as you want, then close the form after the given span. (In this example it is 5 seconds)

Begginnerdev 256 Junior Poster

You could try to create a linq table in your dbml file named 'Duplicate' with the same column names and field lengths.

Then, try to cast the object to the type of Duplicate

Begginnerdev 256 Junior Poster

Why dont you just make use of the splash screen setting in the My Application > Application menu?

8ae345254c4c9bb69e810b0ff6e79a04

ddanbe commented: Good advice! +14
Begginnerdev 256 Junior Poster

What exactly does the exception that is thrown state?

Begginnerdev 256 Junior Poster

Are you using some kind of programming language, or just HTML?

Begginnerdev 256 Junior Poster

Im sorry, I would like to edit my previous post.

You set the command type as well:

For example:

'Insert
data_adapter.InsertCommand = New OleDbCommandBuilder(data_adapter).GetInsertCommand

'Update
data_adapter.UpdateCommand = New OleDbCommandBuilder(data_adapter).GetUpdateCommand

'Delete
data_adapter.DeleteCommand = New OleDbCommandBuilder(data_adapter).GetDeleteCommand
Begginnerdev 256 Junior Poster

Have you tried dynamicly creating the update statement?

For example:

   Try         
        'Insert
        data_adapter.UpdateCommand = New OleDbCommandBuilder(data_adapter).GetInsertCommand

        'Update
        data_adapter.UpdateCommand = New OleDbCommandBuilder(data_adapter).GetUpdateCommand

        'Delete
        data_adapter.UpdateCommand = New OleDbCommandBuilder(data_adapter).GetDeleteCommand

        data_adapter.Update(CType(binding_source.DataSource, DataTable))   
   Catch ex As OleDbException
       MsgBox("ERROR:" & ex.Source & " " & ex.Message, MsgBoxStyle.OkOnly)
       MsgBox(cmd_builder.GetInsertCommand().CommandText, MsgBoxStyle.OkOnly)
   End Try
Begginnerdev 256 Junior Poster

No problem, friend. Please don't forget to close the thread.

Begginnerdev 256 Junior Poster

If you have an extensive knowledge of assembly, you can attempt to decompile it. (This is illegal unless you have a license to do so!!! I do not suggest this!)

If this is not the case, you will have to contact the software vendor/manufacturer and ask if there is a way, or what ports you may need to sniff.

Begginnerdev 256 Junior Poster

Without some sort of documentation or opening the ports on the firewall, you will have no starting point for your sniffer application.

Do you know any of these ports?

Begginnerdev 256 Junior Poster

It sounds like you may have a memory, or hard drive problem.

My suggestion would be to download and run a memory test (Memtest86) and run chkdsk to check the hard drive for any errors.

Begginnerdev 256 Junior Poster

No problem! I hope you get the answers you need!

Begginnerdev 256 Junior Poster

I will flag your post to be moved the the SQL forum where you may receive more help.

Begginnerdev 256 Junior Poster

Try something like this:

Try

'Your code here

Catch ex As Exception
    MsgBox(ex.ToString)
End Try

This will show the error message, the inner exception, and the stack trace all in one dialog box.

Post the image of the resulting error here.