Mike Askew 131 Veteran Poster Featured Poster

Thank you for pointing this out, it was an experiment to see if that was the cause and forgot to replace in code before copying out of Vb.Net

Unfortunately this is not the issue, most appreciated though.

Mike Askew 131 Veteran Poster Featured Poster

The program is currently trying to pull information from three different database tables and compiling the information onto one screen, to do this i am using three different connections and a function to handle the data at each stage.

The issue is as my code hits PageLoadStage of "2" and runs the QueryDatabase() Function i am encountering an error of: "OleDB exception unhandled: No value given for one or more of the required parameters." This occurs on line 15 of the first code snippet. Can anyone explain this and/or identify any code issues if that is the cause.

Most Appreciated,
Mike

Function QueryDatabase()
        Select Case PageLoadStage
            Case 1
                Con.ConnectionString = DBP & DBS
                Con.Open()
                SQL = "SELECT * FROM tbl_Information WHERE Product_Name = '" & SelectedProduct & "';"
                DA = New OleDb.OleDbDataAdapter(SQL, Con)
                DA.Fill(DS, "Info")
                Con.Close()
                Call InformationRender()
            Case 2
                Con.Open()
                SQL = "SELECT * FROM tbl_Stock WHERE Product_Number = " & SelectedProduct & ";"
                DA = New OleDb.OleDbDataAdapter(SQL, Con)
                DA.Fill(DS, "Stock")
                MaxLocations = DS.Tables("Stock").Rows.Count
                Con.Close()
                Call InformationRender()
            Case 3
                Con.Open()
                SQL = "SELECT * FROM tbl_Location WHERE Line_Number = '" & SelectedProduct & "';"
                DA = New OleDb.OleDbDataAdapter(SQL, Con)
                DA.Fill(DS, "Location")
                Con.Close()
                Call InformationRender()
        End Select

        If PageLoadStage <> 4 Then
            Call QueryDatabase()
        End If
End Function
Function InformationRender()
        Select PageLoadStage
            Case 1
                lbl_ProductNameV.Text = DS.Tables("Info").Rows(0).Item(1)
                lbl_ProductPriceV.Text = "£" & DS.Tables("Info").Rows(0).Item(2)
                lbl_AdditionalInfoV.Text = DS.Tables("Info").Rows(0).Item(3)
                SelectedProduct = DS.Tables("Info").Rows(0).Item(0)
                PageLoadStage = 2
            Case 2
                lbl_LineNumberV.Text = DS.Tables("Stock").Rows(0).Item(0)
                lbl_SoldbySectionV.Text = DS.Tables("Stock").Rows(0).Item(1)
                lbl_CurrentStockV.Text = DS.Tables("Stock").Rows(0).Item(2)
                lbl_NextDeliveryDateV.Text = DS.Tables("Stock").Rows(0).Item(3) …
Mike Askew 131 Veteran Poster Featured Poster

My project I am working on is a product location system for a large supermarket. My current issue is that the map I am using to display the product location is assembled from rectangle objects which I will then change the colour of when required.

The array storing the locations is dimensioned as LocationArray(x) Where x is equal to the max rows function used on a table in database. Stored information always proceeded with "loc_" and the location. All rectangles are named in accordance with this.

I wish to pull the field name stored in the array (which corresponds to the rectangle to change colour) and be able to change its colour. This is giving me issue as the straight forward command of "LocationArray(x).Color = #" doesnt work as an array does not inherit this property.

Can anyone know how I am able to pull from the array and then use the pulled data to manipulate object it refers to.

Many Thanks in advance,
Mike

Mike Askew 131 Veteran Poster Featured Poster

Thank you so much

Mike Askew 131 Veteran Poster Featured Poster

Alternatively to what Mike has said, if you move your executing code (in form2) to the form "on load" section (of form2) instead of in a separate sub it will execute as form2 starts up.

Is that what your after cs_tx_usa?

Its a simpler way of doing what Mike has said.

Mike Askew 131 Veteran Poster Featured Poster

When using this code I encoutered an error on the following line:

Dim img As Image = Image.FromStream(ms)

Stating: Parameter is not valid.

Any idea why this is occuring?

Mike Askew 131 Veteran Poster Featured Poster

No problem, as i said, if you get stuck put up whats giving you trouble and i'll see if I can solve it :)

Mike Askew 131 Veteran Poster Featured Poster

Ok writing this code without an IDE is proving harder than i originally thought :D If someone else wants to contribute an OLEDB connection then feel free.

whatshername97, i suggest you look at the website which i learnt how to communicate with databases from. It takes you step by step through the process of writing the connection.

I will write one for you but i am off college for christmas now and my macbook pro doesn't have an IDE on it until i bookcamp to windows 7 after christmas :p

The website is as follows:
http://www.homeandlearn.co.uk/net/nets12p4.html

If you follow this tutorial through it should help you. If you get stuck with bits then i can always try sort it for you, but im stuck myself without an IDE as writing code in this text box is not as clear :(

Apologies, but i will assist where possible still :)

kvprajapati commented: Helpful! +11
Mike Askew 131 Veteran Poster Featured Poster

Solving your first issue with mishandling of the calculation.

This is because of how the add subtract multiply divide buttons are coded.

Your program will currently take the 4 when you press and store to mfirst, then overwrite mfirst with the 3 because you only have one primary storage variable. Hence the 5 as result as the program is storing 3 + 2.

To solve this you could use an array to store the added numbers in as this would allow you to have unlimited numbers in a calculation. A third variable would also be another method and the one i shall use for this solution as I had to make a calculator for college last year :)

I have not written any of the following code in VB as i'm on my Mac and got no IDE on here so it may have the odd error. Hopefully not though.

Dim mRunningTotal As Single

Insert the IF function into all four of your button's code

Private Sub btnMultiply_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMultiply.Click

'This will create a total of the calculation to stop any overwriting
If mFirst <> "" Then
mRunningTotal = mRunningTotal + mFirst
End If

mbutton = 3
'Convert into a number and transfer the value from
'The text box on the form into the first number
mfirst = Val(txtDisplay.Text)
txtDisplay.Text = " "
End Sub

Answer changes:

#
Private Sub btnEquals_Click(ByVal sender As System.Object, ByVal e …
Mike Askew 131 Veteran Poster Featured Poster

I will test that code when next have access to visual studio, i do not code on my Mac and still need to bootcamp it to windows 7 :) Will mark as solved etc if it works when i test :)

Mike Askew 131 Veteran Poster Featured Poster

May i suggest changing your email to:

...

As bots do scan forums for emails and add them to spam lists.

kvprajapati commented: Please read forum rules. -2
Mike Askew 131 Veteran Poster Featured Poster

Im guessing the diary entry is written into a textbox?

Few things:
1. Whats the name assigned to the textbox storing the text?
2. Database file location? eg. c:\User\Database.mdb
3. Table name which you wish to store the information in?
4. Does the table just have one column storing the entries? Or are there multiple fields which are in the table. If there is more than one field (column) please list them in the order they appear in database from left-to-right :)

Does this database only need to store one entry? or would it need to be able to store a backlog of entries (needs extra code if storing a backlog)

If i can get that information off you im sure i can write an OLEDB connection to the database to store the information.

Mike Askew 131 Veteran Poster Featured Poster

As the title suggests, i am trying to pull a bitmap image stored in a table location with an OLEObject type to my picture box on the form. The code i am using is as following:

img_ProductPicture.Image = DS.Tables("LocationInfo").Rows(0).Item(5)

The error i am receiving is an InvalidCastException:
Unable to cast object of type 'System.Byte[]' to type 'System.Drawing.Image'

Am i missing something when pulling the image which will display it?

Thanks in advance for responses.

kvprajapati commented: ++rep. +11
Mike Askew 131 Veteran Poster Featured Poster

Aha this solved my issue. The search is now working as i would like it too.

Thank you very much guys :)

Mike Askew 131 Veteran Poster Featured Poster

Ok the SQL returns as it should using the * character instead of a %.

However when this SQL is now executed through my OLEDB connection I get a negative response.

Below is the entire connection code and the textbox check im currently using at the bottom to check for a positive return

CurrentEntry = txt_SearchInput.Text

'Sets the database connection information
        'DBP = Provider
        'DBS = Source
        DBP = "PROVIDER=Microsoft.Jet.OLEDB.4.0;"
        DBS = "Data Source = H:\Computing\Project\ProjectDatabase.mdb"

        'Sets the connection
        Connection.ConnectionString = DBP & DBS
        'Opens the connection
        Connection.Open()
        'Writes the SQL query for product searching
        SQL = "SELECT Product_Name FROM tbl_ProductInformation WHERE Product_Name LIKE '*" & CurrentEntry & "*'"
        'Exectutes the SQL product searching and fills data adapter
        DA = New OleDb.OleDbDataAdapter(SQL, Connection)
        'Fills data sheet from the data adaptor and names the information 'Products'
        DA.Fill(DS, "Products")
        'Counts how many possible products match the search
        MaxRows = DS.Tables("Products").Rows.Count
        'Shuts the database connection
        Connection.Close()

        TextBox1.text = MaxRows

The textbox1.text currently displays as "0" when the connection is run. This is what is confusing me.

Mike Askew 131 Veteran Poster Featured Poster

tbl_ProductInformation

Field: Product_Name

Entries:
Milk
Milkshake
Mushroom

SQL:
SELECT Product_Name FROM tbl_ProductInformation WHERE Product_Name LIKE '%M%'

I believe this should list all three entries in the database.

Mike Askew 131 Veteran Poster Featured Poster

Well momerath, it isn't supporting the clause. Even when i write the SQL in access before swapping it into my code

Mike Askew 131 Veteran Poster Featured Poster

Even when using the % wildcard this will still not solve the handling issue by the OLEDB connector as it simply wont handle complex SQL queries

Mike Askew 131 Veteran Poster Featured Poster

The variable does pull from a text box, the issue is getting the full SQL query to work using OLEDB connection

Mike Askew 131 Veteran Poster Featured Poster

I am currently creating a product lookup system for a project of mine, however from reading around it has come to my attention that an OLEDB connection will not handle the SQL query below as it will not handle more than a simple "SELECT, FROM".

Table: tbl_ProductInformation
Field: Product_Name
CurrentEntry = Variable storing the users entry

"SELECT Product_Name FROM tbl_ProductInformation WHERE Product_Name LIKE '*" & CurrentEntry & "*'"

The outcome of this query is then put into a listbox.

Is there anyway to make the OLEDB SQL query work so that the returned entries will correctly narrow down to the entered text.