G_Waddell 131 Posting Whiz in Training

Hi,
Do you have access to the source code of the class? Is the function ReturnNewStockodes public in the class? What should the ReturnNewStockodes return i.e. a single clsStockcode or a list of them?

Stockcodes = mag.ReturnNewStockodes("admin", "password")

Would imply a list of clsStockcodes where if you only expected a single one you would do something like this:

Stockcodes.Add(mag.ReturnNewStockodes("admin", "password"))

Also while I was typing I noticed you had used ReturnNewStockodes not ReturnNewStockCodes - just in case there is a typo...

G_Waddell 131 Posting Whiz in Training

Hi, Sorry I've never actually done any work with SNMP so I would n't be much help in that regard - is there any documents that came with the hardware? Did you try google?

G_Waddell 131 Posting Whiz in Training

Hi,
What errors do you get and where did you get them?

You need to add a reference in your project to adventnet which I assume is the software that communicates wih your card. - there should be a .dll file somewhere on your machine called aventnet if that is the software that came with your card.

To add a reference you can either open the project properties page and then the References tab Add Reference and browse for the .dll file

OR

In solution explorer ensure the show all files option is on and open the References folder, Right click on it and Add Reference then again browse for the dll file.

G_Waddell 131 Posting Whiz in Training

Hi,
You need to apply an UPDATE statement. You can either define one for your adapter via the UpdateCommand property (OLEDB DataAdapter.UpdateCommand) Or run an Update statement via a OleDbCommand

G_Waddell 131 Posting Whiz in Training

I think he is running the UPDATE to test if he has opened Access in Read Only mode.

As Ancient Dragon says, the data will only be altered if you run an UPDATE, INSERT or DELETE query so don't!

G_Waddell 131 Posting Whiz in Training

Hi,

You just need to modify your code slightly... in your SQL string, LIKE expects a value after it, you wish to use the parameter @Input to supply this value but because you are placing the parameter inside a string '%@Input%' the SQL literaly thinks find a record where lenscode contains "@Input" i.e. it does not read it in as a parameter...

So you can modify your code as follows:

TempCommand.CommandText ="SELECT Lenscode FROM Products WHERE (Lenscode LIKE @Input)" 

'I assume you pass the value into the input so I'll use a variable for you. 
'In your example,  MySearchValue =5
TempCommand.Parameters.AddWithValue("@Input", "%" &MySearchValue &"%")

As an alternative, it may be possible to do this - but I've never tried it...

TempCommand.CommandText= "SELECT Lenscode FROM Products WHERE (Lenscode LIKE '%' + @Input +'%')
G_Waddell 131 Posting Whiz in Training

Hi raajsj,

I think what JorgeM is sugesting is that you have a go at coding it and let us know where you hit problems...

start by writing breaking down what you want to happen into a flow chart then for each stage of the flow chart try to write some code that will carry out the task.

G_Waddell 131 Posting Whiz in Training

Hi That error you have looks like you are passing a parameter into SQL that is of the wrong type or length...

SQL will try to convert but may not be able to do it e.g. passing in a string into a date if SQL can convert it then there is no error but if it can't you get that message.

G_Waddell 131 Posting Whiz in Training

WOW thats a lot of code... Your opening file stream your runnning updates the lot... Not sure why your opening a file stream though.

Anyway i'll give you a basic break down of what I would do:

On my form have the datagrid with a column for each field in the Employee table hiding any columns of fields I didn't want the users to change. I'd have the edit mode set to edit programatically and Multiselect to False.

Also On my form I'd put a hidden textbox for the EmployeeID and textboxes for any Employee Fields that the user can update.

Then I'd add an edit button when the user hits the button, the routine checks for a selected row in the datagrid - it then takes the field values from the selected row (selectedrows(0)) and populates the textboxes including the the employee ID value to the hidden employee ID box

Next Id have a save changes button and this would carryout the actual update. It would read the values from the textboxes and place them into my update statement ensuring the Where clause in the query got the employee ID value from the hidden textbox (not Datagrid) It would then reload the changed data into the datagrid.

chdboy commented: I have made an textfield(Hidden)and point my where clause to it,it has EmployerID field number to it....thanks a lot for the Idea +1
G_Waddell 131 Posting Whiz in Training

Hi
Unfortunately there is no try catch block in VB6... You have to go back to the good old fashioned On Error

Do you want to handle the error in your code? or are you trying to figure out where it occurred?

If you're handling in the code you have two choices:

'Example of sub routine with GOTO
sub myGotoRoutine()

On Error Goto Err_Handler
'..... do what ever
Exit sub
Err_Handler:
'What do you want to do with the Error?
exit sub

'Example of sub routine with resume next
sub myNextRoutine()
On Error Resume Next
'Doing something that could lead to an error    
if Err.Number <> 0 then
        'Handle error
        Err.clear
End if
'...
Exit sub

The On Error Goto Option means that if there is an error go directly to the marked line of code. In the example I've done if there is an error anywhere in the sub routine then the code jumps down into my error handler if not, it will hit the line Exit sub beforehand and not go in.

The On Error Resume Next means exactly that, if there is an error, carry on to the next line of code. In my example I trap and handle the error on the next line.

If you are trying to figure out where it happens, you need to put brek points in your code and step through it.

As an educated guess, I'd say the code is trying to insert a record into a …

G_Waddell 131 Posting Whiz in Training

Why stop at SQL 2008? We have clients with SQL 2012...

G_Waddell 131 Posting Whiz in Training

Hi
This wouldn't call an error but I was wondering why you did this:

If File.Exists(path) = True Then
    Exit Sub
ElseIf File.Exists(path) = False Then
....
End if

Surely if File.Exists is not true then it is false... i.e. why not just "Else" I'm just wondering would the way you've done it not them make another call out to the system.IO to find out if the file was there when you've already established that it isn't?

Not getting at you just curious.

G_Waddell 131 Posting Whiz in Training

Hi,
I always install SQL first. I do this because in the past I got caught out by installing VS first then trying to install SQL server and Management Studio and I couldn't...
I think it may have been on VS 2005 but it could have been 2008.

Anyway it had SQL plugins included with it for SQL CE but they were SQL Service Pack 2 and although it let me install actual SQL it gave me error messages because there was a newer version of SQL installed and Management Studio would not launch.

I thought if I uninstalled VS then tried installing SQL first but it had left the SQL plugins behind - I ended up spending an afternoon going through registry entries trying to nuke them out of it so I could install SQL Server... so now I always put SQL on first.

G_Waddell 131 Posting Whiz in Training

Hi,
Where do you actually write the entry to your setting? Are you saving the updated setting?

G_Waddell 131 Posting Whiz in Training

Hi,

Not sure what you ment by that last comment?

Do you mean you are coding the same code on two different machines?

Do you have a source code versioning application such as SourceSafe or SVN? You would need something like this to check in and out the source code from a central repository to the different machines that you code on. Your code is being held locally on the machine you develop on if you make a change on machine A and don't synch/port that change to machine B then your code is out of step.

If you mean you made the change and have two machines running the program but the change only appeared on machine A it may mean you have to redeploy (Or reinstall,) your program to machine B

G_Waddell 131 Posting Whiz in Training

Hi
How are you using the Update? Are you specifying the Update as the updagte command on the datasource? Or are you doing it in reponse to a button click or something? Could you show Us the code you are using to fire the update event?

Sorry unfortunately SQL Profiler doesn't come with the Express edition of SQL :(

datagridview.SelectedRows will given you a collection of the rows that are selected on the datagridview so if you just want to update the selected rows you'd do something like this:

Dim DGVRow as DatagridviewRow
Dim EmployeeID as integer


For each DGVRow in MyDataGridView.SelectedRows
    EmployeeID = DGRow.Cells(0).value

next

BUT Looking at your code it seams to me your edit is not actually being done in the grid but on textboxes?

In which case, Why not have a hidden employeeID textbox that you populate with the employee Id of the selected row you are editing? Run your update statement using what you know is the correct ID form the textbox and remember to reload the grid.

G_Waddell 131 Posting Whiz in Training

Hi
Try this mod and see what happens:

 While myReader.Read
     SPTexbox.Items.Add(myReader("playernam"))
     SPnumTexbox.Items.Add(myReader("plnum"))
 End While
 conn.Dispose()

i.e. remove the limit on the item count and see if the row appears...

G_Waddell 131 Posting Whiz in Training

@IsaacMessi10
What happened did you get an error? What did it say? Show us your code...

G_Waddell 131 Posting Whiz in Training

Hi,

Row 11 could be different in some way did you manually populate the table? Is there a chance there is a leading or trailing space for example ("United" vs "United ")? Are the team names in the same case ("United" vs "united")

If you remove the clause about the count of the items and just populate the text box does it appear?

G_Waddell 131 Posting Whiz in Training

Hi,

First of all I would not use firstname to identify the record. Say you have 3 people in your database John Brown, John Green and John Smith and you want to update the John Green record you will end up with 3 identical John Green records. Give your employee table a primary key e.g. EmployeeID and place this as a column in the datagridview. (If you don't want the users to see it, you can set its visible value to false i.e. mygrid.columns(0).visible=false)
Now you can use this in your where clause and only the employee you want is updated.

Also you should probably add the items in the where clause as parameters too for consistancy.

What database are you using? If it is SQL Server you should run a SQL profile to see exactly what is being run on the database when you update the grid.

G_Waddell 131 Posting Whiz in Training

Hi,

I'm a bit rusty with this but I don't think you can just copy over the value from one table to another. I think you will have to stream the image out of one table and then put that stream of binary data back in the other table.

I assume you have code to upload the image to the database and read the image in from the database... In this case, you will be combining them both in reverse i.e. read the image from the database and upload it to the other table.

G_Waddell 131 Posting Whiz in Training

As the guys said above, there are ways and means to get around using the word application... It just means you will not be using the Interop application.

G_Waddell 131 Posting Whiz in Training

Hi
Do you still get "&Open Exam" as the result? This looks to me like it is coming from the parent "Open Menu Item" rather than the item you are clicking. You may have to add the handler after you add the Item to the menu.

G_Waddell 131 Posting Whiz in Training

Hi,

WebBrowser.WebBrowser1.Navigate(BookmarksList.SelectedItems)

SelectedItems implies a collection to me - did intellisense highlight it?

I'd say your looking for either

WebBrowser.WebBrowser1.Navigate(BookmarksList.SelectedItem)

Or

WebBrowser.WebBrowser1.Navigate(BookmarksList.SelectedItems(0))

However, given the error message when you tried SelectedItem.Text is telling you text is not a valid member on type string I'd say the first option is the one you want i.e. SelectedItem

G_Waddell 131 Posting Whiz in Training

Ahhh I did wonder...

As tinstaafl says as you dynamically build the list use the AddHandler to point the click event to a common subroutine based on the normal click event.

You can then use the sender parameter to identify which item fired the event.

G_Waddell 131 Posting Whiz in Training

Hi
I take it this is the standard Menu strip class? In which case, you are not actually selecting an item, you are clicking on it.

So what you would do is use the on click event of each item to populate the messagebox or carry out the other actions.

sub item1_Click (byval sender as object, byval e as system.eventargs) Handles item1.click
msgbox(item1.text)
end sub
G_Waddell 131 Posting Whiz in Training

Hi
Are you sure the default format is yyyy-dd-MM HH:mm:ss? Try formating it as yyyy-MM-dd HH:mm:ss (Serial date)

Dim eventdate As String = Format(DateTimePicker1.Value, "yyyy-MM-dd HH:mm:ss")

Also you may want to double check that syntax, - I'm always mixing my months and minutes up hence I usually do this:

Dim eventdate As String 

eventdate = Year(DateTimePicker1.Value) & "-" & Format(Month(DateTimePicker1.Value),"0#") &"-" & Format(DatePart(DateInterval.Day, DateTimePicker1.Value ),"0#") & _
            " " &TimeValue(DateTimePicker1.Value)

I know it should be the same thing but just in case....

G_Waddell 131 Posting Whiz in Training

Hi,

As adam_k said if you are using the word libraries and interop to access word, the users machine must have a copy of Word installed.

Furthermore, if you specifically include references to a Word library you are depending on the user having the same version of Word installed i.e. Word 2003 uses a different library than Word 2010

To get round the library issue it is better to use late binding to access word:

'Example using an included reference to Word library - depends on client having same version

Imports Microsoft.Interop.Word 

dim MyWord as Word.Application
dim MyDoc as Word.Document

MyWord = new Word.Application
MyDoc  = new Word.Document 'I don't think you actually need this line
MyDoc =  MyWord.Documents.Open (FilePath)

'Example using late binding  - uses whatever version found on client
dim MyWord as Object
dim MyDoc as Object

MyWord = createobject("Word.Application") 
'create object will go and find whatever program string matches
MyDoc = MyWord.Documents.Open(FilePath)
G_Waddell 131 Posting Whiz in Training

Hi
I'd say no, a browser only uses the class for CSS formating it can not identify a certain entity by anything other than it's ID field in Javascript and Name when the form is submitted

G_Waddell 131 Posting Whiz in Training

Hi,

Do you mean manipulate Excel without it being installed on the machine or do you just want a way to do it in .net as opposed to vba?

If you don't mind excel being installed on the machine, then you can use Interop. Here is a sample: DevX.com

As for the other, I'm not 100% sure, I did do a project where I was trying to manipulate newer versions of excel as they are basically compressed XML files but I didn't get very far before we had to pull the plug.

G_Waddell 131 Posting Whiz in Training

Hi
You should try posting to the database forum, my MySQL knowledge is limited but someone there should help

The MySql section is here: Web Development, Databases, MySQL

G_Waddell 131 Posting Whiz in Training

Hi
Did you try
m_con.ConnectionString = "Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\MyDB\book.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"

G_Waddell 131 Posting Whiz in Training

Here is a simple example:
Form 1

Sub ShowDetials()
    dim RecordID as integer
    dim DT as datatable     
    Dim DS as new dataset
    Dim DA as new OleDBDataAdapter
    dim mCmd as new OleDbCommand
    dim DetialsForm as new Form2
    'I will assume your datagrid has row selection and the primary key of the record is in cell 0
    dim Conn as new OleDbConnection(Connectionstring)
    conn.open 
    IF MyDatagridView.SelectedRows.Count>0 then
        RecordID = MyDatagridView.SelectedRows(0).Cell(0).value

        mCmd.Connection = Conn
        mCmd.CommandType = CommandType.Text
        mCmd.Text ="SELECT * FROM MyTable WHERE(MyID =" &RecordID &")"
        DA.SelectCommand = mCmd
        DA.Fill(DS)
        DT = DS.Tables(0)
        'now for the putting stuff on to the other form...
        'For speed I'll just stick evrything into a datagridview
        DetailsForm.DataGridView1.Datasource = DT
        DetailsForm.Show()
     end if
End sub
G_Waddell 131 Posting Whiz in Training

Datasetrs and datatables are held in your computers memory they are disconnected from the database so you can update them but when you look at the database table the cahnges are not there. You must run either an update or insert query on the database such as M.Waqas Aslam has done in his example.

To break it down you should do something like this:

  1. Run an insert (or if modifying an existing record, update query on the Database)
  2. Reload the data into your datatable

An alternative is to use the command builder to specify an Update or Insert command for your dataset and when you update the datatable it will run that query.

Sub RefeshData()
    m_dataTable = new Datatable
    m_con.Open()
    m_DA = New SqlDataAdapter("select * from book", m_con)
    m_DA.Fill(m_dataTable)
    m_con.close() 'because dataset etc are disconnected
End sub

sub AddData(ByRef Firstname as string, byref Lastname as string)
    m_con.Open()
    dim mCmd as new sqlcommand()
    mCmd.Connection = m_con
    mCmd.CommandType = CommandType.Text
    mCmd.Text ="Insert INTO book(Firstname, LastName) Values('" &Firstname &"','" &Lastname &"')"
    mCmd.ExecuteNonQuery()
    m_con.close()
    RefreshData()
End sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
m_con.ConnectionString = "Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\book.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"
 RefreshData()
 End Sub
G_Waddell 131 Posting Whiz in Training

Can we see a bit more of your code?

Where are you specifying the Update commands for instance? - You will need more than one as you are updating two tables within your dataset.

G_Waddell 131 Posting Whiz in Training

Show us your code...

G_Waddell 131 Posting Whiz in Training

Hi
This is because your datatable is held in the computers memory - it is not the database table rather a disconnected query result held there for you.

You must either run a command to update the SQL table and then refresh. Or update the Database table and then the datatable as you are doing.

G_Waddell 131 Posting Whiz in Training

Glad to be of help, remember to mark as solved...

G_Waddell 131 Posting Whiz in Training

Hi
I suspect the web page you are inputting the data into is performing some sort of client side validation before enabling the submit button. So you are going to have to make your form wait until the button is enabled.

Before VB.Net we used to use Do Events but I believe the way .Net framework handles this is different now so you will have to use a Thread.Sleep call after you have inputted the data. This will block the current thread for the specified number of milliseconds.

G_Waddell 131 Posting Whiz in Training

You could also try the ISNULL clause e.g.

SELECT ISNULL(MyCol, '') as MyCol From MyTable

Would return either the value in the MyCol column or an empty string if it was null

G_Waddell 131 Posting Whiz in Training

Hi
Yes because the data is not coming from an individual table you will need to run the DELETE / UPDATE / INSERT queries as a seperate query for each table.

sub UpdateHumanResource()
dim cmd as OleDbCommand
dim sSQL as string
....
con.open

sSQL ="UPDATE Academic SET FirstLevel ='" &cmbFirstLevel.Text &"', FirstAward ='" &txtFirstAward.Text &"' etc..."

cmd = new OleDBCommand
With cmd
     .CommandType = CommandType.Text
     .CommandText = sSQL
     .Connection = con
End With
cmd.ExecuteNonQuery

sSQL ="UPDATE tblDetails ...."
cmd = new OleDBCommand
With cmd
     .CommandType = CommandType.Text
     .CommandText = sSQL
     .Connection = con
End With
cmd.ExecuteNonQuery
end sub
G_Waddell 131 Posting Whiz in Training

Hi,

Do you mean you get a phone number and you want to display in that format?

dim MyPhoneNumber as string
....
Textbox1.Text = MyPhoneNumber.SubString(0,3) &"-" &MyPhoneNumber.SubString(3)

Or do you want to force users to enter in that format? Or Both?
In that case you need The Masked Edit Textbox
Or you will have to use A Validation Class - I never used one before though.

G_Waddell 131 Posting Whiz in Training

I have no idea how you would get it for free... I generally code my own stuff

G_Waddell 131 Posting Whiz in Training

Ajax would allow you to change and populate the tab each time without refreshing the whole page so it could work for you.

G_Waddell 131 Posting Whiz in Training

Hi
Did you set up the columns beforehand?

hmmm must be returning the index of the row - I thought it would just add it. You could try this instead:

While reader.Read
    MyNewRow = DataGridView1.Rows(0).Clone
    'Do Whatever
    DataGridView1.Rows.Add(MyNewRow)
End while
G_Waddell 131 Posting Whiz in Training

In Your Add Columns routine add ALL the columns you need, those from the database and the extras.

Next in your RunSQL routine, loop through the result set and add new rows to the datagridview as you go:

dim MyNewRow as DatagridViewRow
While reader.Read
 myNewRow = DataGridView1.Rows.Add
    MyNewRow.Cells(0).Value = reader.Item("Patient Account Number").ToString
    'And so on....
    'For Non DB cells just set the value
    myNewRow.Cells(1).Value = MyNonDBValue
    'if you have a Checkbox column in cell 2 then and wish to check it
    MyNewRow.Cells(2).Value = True
End While

You could always go back and populate any of the extra cells if required.

IMPORTANT
You will not be databinding the grid as you are placing extra columns

If for any reason you wish to run these routines on an already populated grid, you should clear the Columns and Rows first or you will append the new columns or rows to the Existing data.

G_Waddell 131 Posting Whiz in Training

It looks like you have tried to enter an invalid time format

3.00:00:00 you have a decimal point not a : you mean 3:00:00:00 Or 3:00:00 either way they are the same

G_Waddell 131 Posting Whiz in Training

You have to add the parameter as an Output Parameter BUT an UPDATE statement will not produce one and neither would an INSERT you'd have to run a select query for it.

What kind of database are you using?

If you are using Micorsoft SQL Server then you do this with a Stored Procedure instead of querying on the fly. i.e. within the Stored Procedure run the INSERT statement then output the SCOPE_IDENTITY() to get the identity field value of the record you just created.

G_Waddell 131 Posting Whiz in Training

I've never worked with the Windows Music player before so here is a high level view of what I would do.
You will need to store the tracks listing either in a file or database unless you can access directly from the player.

Take a count of the track you have availble and use the random class to randomly pick a track.. something like this:

Private Function RandomTrackPicker(MaxValue as Integer, _
    Optional ByVal MinNumber As Integer = 0) As Integer

      'initialize random number generator
        Dim r As New Random(System.DateTime.Now.Millisecond)

      'if passed incorrect arguments, swap them
        'can also throw exception or return 0

        If MinNumber > MaxNumber Then
            Dim t As Integer = MinNumber
            MinNumber = MaxNumber
            MaxNumber = t
        End If

        Return r.Next(MinNumber, MaxNumber)

    End Function

Then whatever number returns should be a random number of a track to play.

G_Waddell 131 Posting Whiz in Training

Do you really need it to be all entered in one go?

It would be a lot easier to enter course by course...

I would put the education levels into a dropdown list that the user select and the rest in text boxes that the user fills in.

You would then run a oleldb command with a SQL Insert query to add the details.