Begginnerdev 256 Junior Poster

One easy way to do this would to be pre-query the database with the number that the user is wanting to insert. If the number doesn't exist, then allow them to alter, if it does, prompt them.

This will safeguard from those nasty error messages.

Begginnerdev 256 Junior Poster

You can not alter autonumbers from queries. They are fixed values.

Change the column to integer.

That should fix your problem, but you can't have two matching numbers.

Begginnerdev 256 Junior Poster

Is your code wrapped in a loop somewhere?


Can you please post a larger portion of the code so we can analyze it?

Begginnerdev 256 Junior Poster

One easy way to find errors in code is to insert a break point.

Then step over the code until you find where it it throwing the error.

Hope this helps.

Begginnerdev 256 Junior Poster

Is po_number an autonumber? Just curious.

Begginnerdev 256 Junior Poster

You could also use:

string.Split(New Char(","c)
Begginnerdev 256 Junior Poster

Hello my fellow Danniwebbers,

I am going crazy here.

I have been messing around with the scanning packages(WIA and TWAIN) and have gotten WIA to work, but not as intended. At first I used the common dialog to show a Image Aquisition Wizard, but that did not return desired results. Next was twain, but still no help there. All I managed to find was the same C# program over and over and over again, "TwainGUI". A program written by NETMaster on codeproject.

What I would like to do is scan from the ADF and save immediately to the users working directory. The problem is I can't get WIA to keep scanning until the ADF is empty.

I have tried the ShowAquireImage, but I don't want the dialog to pop up every time until the tray is empty. I have also tried capturing the COMexception thrown from the scanner when the feeder is empty.

The primary concern is:


Psudo Code:

Start:

"Set scan settings"

"Is Feeder Empty?"
No - Scan
Yes- STOP

Save

Exit

Does anyone anywhere have any information on this? I am pulling my hair out here. T_T

Begginnerdev 256 Junior Poster

You could cheat a little and create buttons for each take picture, then hide them.

Then create one more button, and on that button.click event call the:

Camera1Button.performclick
Camera2Button.performclick

ect....

They wont be EXACTLY the same time, but they will be extremely close.

Begginnerdev 256 Junior Poster

You can create a naming scheme, which you already have. Then generate that name on runtime. I am assuming you are using a database backend?

If so, you can use a primary key as a varchar. Generate the key in application, on save, by:

dim datestr as string = today.year & today.month & today.day & today.second 'varries on your creation time.
'Will create a string = "2012020935"
Begginnerdev 256 Junior Poster

That is what I have scannedimages for, but for some reason it does not want to keep the order of the panels post rearrange. I would like to have the ability to move the panels and when the user presses "Save", the panels are then saved in their current order. The problem is, they are saved in the order they were scanned in. :(

Begginnerdev 256 Junior Poster

Would that not mess up when:

6312 + 500 = 6812 \ 1000 = 6 * 1000 = 6000
6312              \ 1000 = 6 * 1000 = 6000

Or am I just missing some language side rounding method?

Begginnerdev 256 Junior Poster

Hello my fellow DanniWebbers, it is me againg. I have yet another question for you guys and gals.


I have a parent panel with child panels that contain images. I am looping through the panels to save the images in the order the panels appear in the parent panel.


I am using:

for p as Panel in ImagePanel.Controls
  scannedImages(j) = p.BackGroundImage
  j += 1
next

I can also re-arrange the panels via mouse. The problem is that when they are rearranged, they do not retain their order when saved.. They simply are saved in the order they were added to the parent panel.

So my question is, does the for loop use the index set when adding the panel? If so, how can I manipulate the index in runtime while arranging the panels via mouse.

Begginnerdev 256 Junior Poster

Solved. All that had to be done is loop through and pull all objects of the panel type, and store them in the arrray. Then post all remain objects back to the empty panel.

Code:

Try
            If IsNothing(selectedPanel) = False And IsNothing(myPanels) = False Then
                Dim i As Integer = 0
                For Each p As Panel In ImagePanel.Controls
                    If p Is selectedPanel Then
                        tmpPanels(i).pnl = Nothing
                        i += 1
                    Else
                        tmpPanels(i).pnl = p
                        i += 1
                    End If
                Next

                ImagePanel.Controls.Clear()

                For z = 0 To tmpPanels.Count - 1
                    If IsNothing(tmpPanels(z).pnl) = False Then
                        createPanel(tmpPanels(z).pnl.Name)
                    End If
                Next
                For j = 0 To tmpPanels.Count - 1
                    tmpPanels(j).pnl = Nothing
                Next
            Else
                MsgBox("Please select a panel to delete.", MsgBoxStyle.OkOnly)
            End If
        Catch ex As Exception
            MsgBox("Exception from: " & ex.Source & vbCrLf & ex.Message & vbCrLf & vbCrLf & ex.StackTrace.ToString, MsgBoxStyle.OkOnly)
            Return
        End Try
Begginnerdev 256 Junior Poster

OK, I have rewritten my code about 9 times now.

Here is what I have now.

'Allows the user to delete the currently selected tab on the tab control.
        Try
            If Not (selectedPanel Is Nothing) And Not (myPanels Is Nothing) Then

                For i = 0 To myPanels.Count - 1
                    If myPanels(i).pnl Is selectedPanel Then
                        myPanels(i).pnl = Nothing
                    End If
                Next

                For i = 0 To myPanels.Count - 1
                    If (i + 1) < myPanels.Count Then
                        If Not (myPanels(i).pnl Is Nothing) And Not (myPanels(i).loc = Nothing) Then
                            tmpPanels(i).loc = myPanels(i).loc
                            tmpPanels(i).pnl = myPanels(i).pnl
                            myPanels(i).loc = Nothing
                            myPanels(i).pnl = Nothing
                        ElseIf myPanels(i).pnl Is Nothing And Not (myPanels(i).loc = Nothing) And Not (myPanels(i + 1).pnl Is Nothing) Then
                            If (i + 1) < myPanels.Count Then
                                tmpPanels(i).loc = myPanels(i).loc
                                tmpPanels(i).pnl = myPanels(i + 1).pnl
                                myPanels(i).loc = Nothing
                            End If
                        ElseIf Not (myPanels(i).loc = Nothing) And myPanels(i + 1).pnl Is Nothing And myPanels(i + 1).loc = Nothing Then
                            myPanels(i).loc = Nothing
                        End If
                    End If
                Next
                ImagePanel.Controls.Clear()

                For x = 0 To myPanels.Count - 1
                    myPanels(x).pnl = Nothing
                    myPanels(x).loc = Nothing
                Next

                For x = 0 To tmpPanels.Count - 1
                    If Not (tmpPanels(x).pnl Is Nothing) And Not (tmpPanels(x).loc = Nothing) Then
                        createPanel(tmpPanels(x).pnl.Name)
                    End If
                Next

            End If
        Catch ex As Exception
            MsgBox("Exception from: " & ex.Source & vbCrLf & ex.Message & vbCrLf & vbCrLf & ex.StackTrace.ToString, MsgBoxStyle.OkOnly)
            Return
        End Try

Basicly what I am trying to do is this.


x = panels _ = drawing location of panel

X …

Begginnerdev 256 Junior Poster

Getting closer. Found possible issue? Loop through and push panel values forward?

Begginnerdev 256 Junior Poster

Do you have loop in your code?

Begginnerdev 256 Junior Poster

Is there any way to pull from the location INSIDE the panel? I think that is my problem. When I am scrolling down to delete the panel, they shift up to the panel above and is set to the size of the panel that I see. So if I am looking at a 1/4 of the panel for the one above, and I delete the one below - The one below is shifted up the location of the first, which makes only 1/4 of it viewable.

Anyone have any suggestions?

Begginnerdev 256 Junior Poster

I have it some what working. Now it shifts up, but it pushes the top panel "off screen"

Here is the code that works for the shift:

'Allows the user to delete the currently selected tab on the tab control.
        Try
            If Not (selectedPanel Is Nothing) And Not (myPanels Is Nothing) Then
                For i = 0 To myPanels.Count - 1
                    If Not (myPanels(i).pnl Is Nothing) Then
                        If myPanels(i).pnl.Name = selectedPanel.Name Then
                            For j = i + 1 To myPanels.Count - 1
                                If j <> myPanels.Count And Not (myPanels(i).pnl Is Nothing) And Not (myPanels(j).pnl Is Nothing) Then
                                    myPanels(j).pnl.Location = myPanels(i).pnl.Location
                                    myPanels(i).pnl = myPanels(j).pnl
                                End If
                            Next
                            ImagePanel.Controls.Clear()
                            ImagePanel.Refresh()
                        End If
                    End If
                Next
                For i = 0 To myPanels.Count - 1
                    If Not (myPanels(i).pnl Is Nothing) Then
                        ImagePanel.Controls.Add(myPanels(i).pnl)
                    End If
                Next
            End If
        Catch ex As Exception
            MsgBox("Exception from: " & ex.Source & vbCrLf & ex.Message & vbCrLf & vbCrLf & ex.StackTrace.ToString, MsgBoxStyle.OkOnly)
            Return
        End Try
Begginnerdev 256 Junior Poster

Are you wanting to convert to ASP with VB.net or ASP with C#?

There are two different code languages that drive ASP.net.

Begginnerdev 256 Junior Poster

Hello my fellow Daniwebbers, I have a modest question for you.


I have a panel, which contains child panels.

I have code the alows the user to delete the selected panel, but can't figure out how to refresh the parent panel with the deleted panel gone. When I use the refresh, the empty space is still there... So, I wrote a block of code that is supposed to "shift" all of the panels up to the deleted panels position. But when the code is executed, the panel to delete is deleted...along with everything above it. :S

Here is my code.

'Allows the user to delete the currently selected tab on the tab control.
        Try
            If Not (selectedPanel Is Nothing) And Not (myPanels Is Nothing) Then
                For i = 0 To myPanels.Count - 1
                    If myPanels(i).pnl Is selectedPanel Then
                        For j = i + 1 To myPanels.Count - 1
                            If j <> myPanels.Count Then
                                myPanels(j).loc = myPanels(i).loc
                                myPanels(i).pnl = myPanels(j).pnl
                                j += 1
                            End If
                        Next
                        selectedPanel.Dispose()
                        ImagePanel.Controls.Clear()
                        ImagePanel.Refresh()
                    End If
                Next
                For i = 0 To myPanels.Count - 1
                    If Not (myPanels(i).pnl Is Nothing) Then
                        ImagePanel.Controls.Add(myPanels(i).pnl)
                    End If
                Next
                Return
            End If
        Catch ex As Exception
            MsgBox("Exception from: " & ex.Source & vbCrLf & ex.Message & vbCrLf & vbCrLf & ex.StackTrace.ToString, MsgBoxStyle.OkOnly)
            Return
        End Try

"Edit..."
More info:

'Declaration of myPanels
dim myPanels(100) as panelArray


'Declaration of panelArray
    Public Structure panelArray
        Public pnl As Panel
        Public loc As System.Drawing.Point
        Public siz As …
Begginnerdev 256 Junior Poster

Works perfectly, thank you very much!

Begginnerdev 256 Junior Poster

I will try this, thank you.


What I will be doing is viewing multiple images and cascading them as "pages" to create one multipage tiff.

Begginnerdev 256 Junior Poster

Check your database to make sure that the data type is set to date time.

If that is not the case, if you are using a string, parse as a date then pass into the string.

You can use Cdate to do this.

Begginnerdev 256 Junior Poster

I have a question for all of my fellow Daniwebbers.

If I place a panel within another panel, can I "click" the panel later?

In other words, if I am able to click the panel, can I reference that panel in code for manipulation? Such as flipping or rotating the panel orientation.


Edit...

Here is what I have so far, but it requires the user to type the "index".

If CInt(TextBox1.Text) <> 0 Or TextBox1.Text <> "" Then
                'Allows the user to rotate the image using the text box and rotate button
                ImagePanel.Controls(CInt(TextBox1.Text) - 1).BackgroundImage.RotateFlip(RotateFlipType.Rotate90FlipNone)
                ImagePanel.Controls(CInt(TextBox1.Text) - 1).Refresh()
End If

I should also add that the panels that are added into the parent panel are created on runtime.

Thanks,
BegginnerDev

Begginnerdev 256 Junior Poster

Ah ha!

I have found the answer.

Import the wia library.

imports wia

'declare needed components.
dim dev as device
dim cd as commondialog


'use in form load or button click
dev = cd.showselectdevice(wiadevicetype.scannerdevicetype, false)

'This is the best part....MULTIPAGE TIFFS WITHOUT TROUBLE!
cd.showaquisitionwizard(dev)

'This will open the wizard with all functionality for the scanner.

Makes life MUCH easier.

Begginnerdev 256 Junior Poster

Can you post the code you are using to sort?

Begginnerdev 256 Junior Poster

This is a module that can be used to save tiff images pass in from a file dialog.

This module was translated from C# to VB.net, and the original project can be found here.

I do not claim rights to this code.

You can copy this code straight down into an empty module, without having to import any dlls. Everything uses direct library references.

Hope it helps some one.

Begginnerdev 256 Junior Poster

My post above singles out the first column in the row. Listviews are pain do deal with when working with databases. This allows you to used the selected row to perform a query.

Begginnerdev 256 Junior Poster

Connection will be the name of the your connection.

For you connection would be "con"

so

da.UpdateCommand = New OleDBCommand(sqlString, con)

You will be able to place the code anywhere after the declaration of the data adapter and string, but before the da.Update is called.

Begginnerdev 256 Junior Poster
dim sqlString As String = "INSERT INTO Users (Username,Password,First Name,Second Name,DOB,Address,License Number) VALUES ('" & txtUsername.text & "','" & txtPassword.text & "','" & txtForename.Text & "','" txtSurname.Text & "','" & txtDob.text & "','" & txtAddress.Text & "','" & txtLicNo.Text & "')"


da.UpdateCommand = New OleDbCommand(sqlString, connection)

You might want to check the sql string for errors, just typed it into the text widow.

Begginnerdev 256 Junior Poster

After beating my head into the wall 1,000 times over when working with listview, I have discovered an easy way.

By:

Dim index as String

For Each sItem As ListViewItem In DatabaseListView.SelectedItems
       index = sItem.Text
Next

'this will select the item at the start of the row that is clicked. 
'you can use that item to then reference your database.
Begginnerdev 256 Junior Poster

You could do as hericles stated and just store a path reference into the database.

You could get it application side and then assign it to a string. Then pass the string in to the database. You will have to make sure that everything is spelt correctly ect.

Begginnerdev 256 Junior Poster

Sorry forgot to add:

Dim newRow As DataRow

My appologies friend.

Begginnerdev 256 Junior Poster

Create a datatable:

'Where table name is the table in the db.
 Dim dt As DataTable = ds.Tables("tablename")

 Dim newRow As DataRow
'Setting up the table for the data
 newRow = dt.NewRow()
'You should replace "column1" and "column2" with the column name in your db.
 newRow("column1") = TextBox1.Text
 newRow("column2") = TextBox2.Text
 dt.Rows.Add(newRow)

'Updating db
da.Update(ds, "tablename")

Then fill the listbox.

Then loop through and check between the values. If the value matches column one, populate the text box from column two.

Begginnerdev 256 Junior Poster

I have also had issues in the past when using the wildcard, see if you can directly reference the names to the columns. I have had the wildcard jumble everything together with no order. It seems to do it mostly when there are empty columns in the tables, so it pushes the rest of the data together.

Begginnerdev 256 Junior Poster

I use a datatable method, which is close to what you are doing.

Here is what I do:

'Where table name is the table in the db.
 Dim dt As DataTable = ds.Tables("tablename")

 Dim newRow As DataRow
'Setting up the table for the data
 newRow = dt.NewRow()
'You should replace "column1" and "column2" with the column name in your db.
 newRow("column1") = TextBox1.Text
 newRow("column2") = TextBox2.Text
 dt.Rows.Add(newRow)

'Updating db
da.Update(ds, "tablename")

See if this helps.

Begginnerdev 256 Junior Poster

I see that you are clearing your text boxes then asigning them to the ds. Are any of your fields set to be not null? If so, then you may be having a problem there.

Begginnerdev 256 Junior Poster

Did you also notice you had 2 connection disposes for the same connection?

con.Dispose()
        cmd.Dispose()
        con.Dispose()
Begginnerdev 256 Junior Poster

It will not convert it, but I managed to convert it by hand.

Thank you for the reference site.

That will come in handy in the future.

+1 for you.

Begginnerdev 256 Junior Poster

Hello my fellow Daniwebaholics!

I know it is kindof off the wall, but I need help converting a piece of C# code to VB.net.
I know a little C#, but not enough to be able to convert complex syntax from one to the other.

Here is the code in C#:

p.Location = new System.Drawing.Point(((Panel)PanelContainer[PanelContainer.Count - 1]).Left, ((Panel)PanelContainer[PanelContainer.Count - 1]).Bottom + 5);

Where PanelContainer is an arrayList.

Any help would be GREATLY appreciated.

Thank you,
BegginnerDev

Begginnerdev 256 Junior Poster

Just for the sake of redundency, have you tried:

SQLstr = "INSERT INTO users (username,password) VALUES ('" & txtUserName.text & "','" & txtPassword.text & "'"

Maybe it has something to do with case sensitivity?

If not, have you checked to make sure that the names are correct? (I know it's stupid, but it helps eliminate problems")

Begginnerdev 256 Junior Poster

As reverend stated. It is much easier to create a settings variables such as ServerIP that holds the value from the server ip text box.

That way, on form_exit you can call:

with My.Settings
   .ServerIP = txtServerIP.text
   .Save
end with

That way you can call it on the next form load, or even call it without needing to pull the values from a text box.

On form load.

with My.Settings
   txtServerIP = .ServerIP
end with
Begginnerdev 256 Junior Poster

Did you try removing the second

WebBrowser1.ScriptErrorsSuppressed = True

And...

For abc = Cint(TextBox5.Text) To Cint(TextBox6.Text) Step 1
Begginnerdev 256 Junior Poster

Sorry, my fault. I had forgotten you did so.

Have you checked to be sure you have permissions to access the database?

Begginnerdev 256 Junior Poster

Bump..

Anyone have any clue what I am doing wrong? I have scoured the internet all day for the last 4 day looking for a reference. Is it safe to assume it is a lost cause?

Begginnerdev 256 Junior Poster

Wrap the code in a try/catch block. Then use msgbox(ex.message) in the catch.

Begginnerdev 256 Junior Poster

Wrap your code in a try/catch and like this:

try
'Your code here
catch ex as exception
msgbox(ex.message)
end try

This will tell you what line your error is on.

Begginnerdev 256 Junior Poster
Begginnerdev 256 Junior Poster

I am not having any luck with scanning multiple pages from the ADF. I have scoured the net from top to bottom looking for an article similar to what I am needing, but to no avail. It is starting to get frustrating.

So far I have this:

Dim CD As New WIA.CommonDialog
        For i = 0 To 1000
            Try
                F = CD.ShowAcquireImage(WiaDeviceType.ScannerDeviceType)
                F.SaveFile("C:\Users\***********\Desktop\" & DocumentNameTextBox.Text & ".tif")
            Catch ex As Exception
                If InStr(ex.Message, "Exception from HRESULT: 0x80210003") Then
                    Exit For
                Else
                    MsgBox(ex.Message)
                End If
            End Try
        Next

This works, but I don't need the select device prompt every time. I just want to select the ADF once, therefore, the ADF will be used to scan until the feeder is empty.

I have also tried numerous open source libraries that say they use the ADF but in reality they use the flatbed. -_-

I am beginning to get very discouraged about finding a solution that doesn't cost major cash.

Begginnerdev 256 Junior Poster

The WIAAL page said:

Windows Image Acquisition Automation Library v2.0 is only supported on Windows XP with Service Pack 1 installed.

Is this an old article, or is it just Microsoft being....well....Microsoft?