G_Waddell 131 Posting Whiz in Training

Hi,

I always try and do all my declarations at the top of the routine, that way you can find them easily and see if you have already declared it. I suspect you my have already declared the MyUserID if you move your mouse over the green line, is there a message that pops up?

G_Waddell 131 Posting Whiz in Training

Hi,

Have you declared MyUserID? i.e. Dim MyUserID as String

You Tab page declaration is wrong and the line you have highlighted is wrong:
Dim newPage As New TabPage() should be Dim newPage As TabPage
Then instead of newPage = TabPage you should put newPage = New TabPage

You do realise I'm just giving you pointers and examples? I'm not going to sit here and write the whole routine for you.

G_Waddell 131 Posting Whiz in Training

Also this line is wrong too:

VisitLabel.Text = "Repeat Data" 

Should be:

VisitLabel.Text = DR("Repeat Data")
G_Waddell 131 Posting Whiz in Training

Hi,
Sorry you have misunderstood me. I was using a parameterised Query string. These lines here are wrong:

cmd.CommandText = "Select * from Repeat where PERID ='" & ComboBox1.SelectedValue.ToString & "'"
cmd.Parameters.Add("@PERID", MyUserID)

They should be something like this:

cmd.CommandText = "Select * from Repeat where PERID =@PERID"
MyUserID = trim(ComboBox1.SelectedValue.ToString)
cmd.Parameters.Add("@PERID", MyUserID)

The reason for using parameters is to avoid a nasty technique called SQL injection - basically people place SQL code inside your inputs e.g. someone puts "'; DELETE FROM Repeat;" into your combo box.
If you are passing the whole SQL command in as a line of text you could get Select * from Repeat where PERID =''; DELETE FROM Repeat; The database server would read this as two seperate SQl queries and the second one would wipe your table. By using a parameter the database server knows this is a parameter and will treat it as such.

G_Waddell 131 Posting Whiz in Training

To explain further:

We created a new Dataset, we used an OLEDBDataAdaptor to fill the dataset with the results of executing a OleDBCommand.
The Command Executed the SQL SELECT statement we passed into it as Command text.

When we filled the dataset what we actually did was to add a new Datatable to our dataset with the records we returned from our query. We then selected the datatable (it was the only one in the Dataset therefore had an index of zero,) and we got a count of the rows in the datatable.

As we had one or more rows we set up a loop (For each DR in DT.Rows) to get each DataRow in the DataTable.

For each Datarow we created a new tab page and populated it.

G_Waddell 131 Posting Whiz in Training

Hi

I dimmed the DR as a datarow and the datarow is coming from the Datatable i.e. it is a row in the DataTable.
The Datatable has been populated by the result of your SQL SELECT statement, so each Row in the Datatable is a returned row from your statement and each Column in each row equates to the Fields you selected from your database i.e. "PERID" is a field in your Access Database table and if included in your SELECT statement would be a Column in your DataTable, DR("FieldName") is just a short hand way of typing DR.Columns("FieldName").Value

G_Waddell 131 Posting Whiz in Training

Hi

You'd need to add the controls to the Tabpage (Labels Textboxes etc) and populate...

dim VisitLabel as Label
dim VisitDateBox as TextBox


for each DR in DT.rows
    newPage = New TabPage        
    newPage.text = "Repeat - " &RecCount
    'I'll add a label and a textbox as an example you can experiment with position etc.
    VisitLabel = new Label 
    VisitLabel.text = "Return Date"
    newPage.Controls.add(VisitLabel)
    VisitDateBox = new TextBox
    VisitDateBox.Text = DR("VisitDate")
    newPage.Controls.add(VisitDateBox)

    RecCount +=-1        
    TabControl1.TabPages.Add(newPage)    
 next
G_Waddell 131 Posting Whiz in Training

Hi,
I take it QReaderQ is a datareader? The problem with that is that it is forward only i.e. you have no way of counting the rows returned until you have gone through it and once you have looped through you have to reopen.

If you use a DataAdapter to get a Datatable then you can find out the number of rows in advance and you can loop through as many times as you like.

dim DS as new dataset
dim DA as OLEDBDataadapter
dim cmd as new OLEDBcommand
dim DT as datatable
dim RecCount as integer
Dim conn As New OleDbConnection(connection)
dim DR as datarow
cmd.CommandText ="SELECT * FROM Visits WHERE (UserID =@UserID) ORDER BY VisitDate Desc"
cmd.Parameters.Add("@UserID", MyUserID)

DA.SelectCommand = cmd
DA.Fill(DS)
DT = DS.Tables(0)

RecCount = DT.Rows.Count
TabControl1.TabPages.clear()
IF RecCount > 0 then
    for each DR in DT.rows
        newPage = New TabPage
        newPage.text = "Repeat - " &RecCount
        '.....
        RecCount +=-1
        TabControl1.TabPages.Add(newPage)
    next
end if
G_Waddell 131 Posting Whiz in Training

Hi,

You've concatenated the fields in your query and you want to split them back out again?

You could try using the split function on the space character:

dim Names() as String
....

Names = dgvProfessor_bs.Rows(e.Rowindex).Cells(1).Value.Split(New Char() {" "c})

textboxFirstName.Text = Replace(Replace(Names(0), ",",""),".","")
TextboxLastName.Text = Replace(Replace(Names(1),",",""),".","")
TextboxMiddle.Text = Replace(Replace(Names(2),",",""),".","")
G_Waddell 131 Posting Whiz in Training

Hi
Do you know what user the program is running under? Is it a local machine user? You will need to use a network domain user account so that both machines will recognise it and grant this account access under SQL server Management studio.

G_Waddell 131 Posting Whiz in Training

You need to use a stream to to stream the data into your RichTextbox

G_Waddell 131 Posting Whiz in Training

Hi,

Can you give us what code you have so far and we can take it from there?

As I understand it, for a given person, you want to retrieve their "visits" from the database and display the details of each visit in a separate tab page in the Tab control?

G_Waddell 131 Posting Whiz in Training

Hi,
Your code to get the sections looks wrong, you should be passing in the whole rich text box text not data1 and I'm not sure you are calculating the point correctly i.e. sLeft = left(rtb.text, rtb.selectionstart-1) would get you the text in the rich text box just before the selection. sRight = mid(rtb.text,rtb.SelectionStart) would get you the text in the textbox from the selection start to the end of the textbox.

G_Waddell 131 Posting Whiz in Training

In terms of the law, once when I was younger and more foolish I was running late to the wedding of my then girlfriends sister. I had been held up in traffic so when I got to an open bit of dual carrage way I nailed the car and (of course,) was pulled over by an unmarked police car that I overtook doing 100mph in a 60mph zone... Luckily for me I was driving (legally,) with a driving licence from another jurisdiction so he could only give me an on the spot fine - if I had the same licence for the jurisdiction I was in I would have lost it and been in court - but I was being an idiot and would have deserved it.

In general terms: Last year I caught a mild virus but unknown to me I had been living my whole life with a heart defect where I had a short circuit in the nerves that control when it beats that would ramdomly cause a flutter effect - whatever this virus did it caused that short circuit to keep firing which caused my heart rate to keep acelerating. I was away from home on business so I cut my trip short and drove about 80km to my doctors while having these symptoms - he got me to get my wife to come and pick me up and take me to hospital - when I got there I had a heart beat of 200 bpm …

G_Waddell 131 Posting Whiz in Training

Yes, clearer definition and sample code would help...

G_Waddell 131 Posting Whiz in Training

So the issue is in your insert command, do you know what types of parameters the database is expecting? For example, I'll assume the sal_Quantity field in your Database is numeric maybe a decimal figure? so I would ensure I'm passing in a valid decimal value and not a text values:

dim Sal_Quantity as Decimal

'...
'Set a default valid value
Sal_Quantity = 0
IF isnumeric(tbox_Quantity.text.trim) then
    'we know now we can convert to numeric value
    Sal_Quantity = Cdec(tbox_Quantity.text.trim)
end if
'....
'Insert our valid value either 0 or a decimal
InsertCommand.Parameters.Add(New OleDb.OleDbParameter("@sal_Quantity",Sal_Quantity))
G_Waddell 131 Posting Whiz in Training

Hi,
As far as I can see there are two ways to do this, just use the replace function:

IF Instr(StartPosition,HTMLopt.rtb.text, txtSearchTerm.text,SearchType) = 0 then
    Messagebox.show("String :'" &txtSearchTerm.Text &"' not found", "No Matches", MessageboxButtons.OK, MessageboxIcon.Asterisk)
Else
    HTMLopt.rtb.Text.Replace(txtSearchTerm.Text,txtReplacement.Text)
End if

Or if you fancy scrolling through the textbox and replacing as you go something like this:

Clipboard.SetText(txtReplacementText.Text)
StartPosition = Instr(StartPosition,HTMLopt.rtb.text, txtSearchTerm.text,SearchType)
Do Until StartPosition = 0
    HTMlopt.rtb.Select(StartPosition-1, txtSearchterm.text.length)
    HTMLopt.rtb.ScrolltoCaret()
    application.DoEvents()
    HTMLopt.rtb.paste()
    Instr(StartPosition,HTMLopt.rtb.text, txtSearchTerm.text,SearchType)
Next
G_Waddell 131 Posting Whiz in Training

hi,

If you do a view source can you see the <img> tags? If they are there, I suspect they are pointing to a local path relative to your word doc - If memory serves correctly when you save a word file to HTML it creates a folder to keep images etc in. However, depending on how Word embeds the image, they may not get converted across - I'm a bit rusty on this.

G_Waddell 131 Posting Whiz in Training

Hi,
They've cross posted on your post...
I suspect your query is only returning a single record. You are reading the results in two different places though. You have the following line (#16):
datareader.read() This will read in the record from the datareader but you don't do anything with it...
Then you put a loop

while Datareader.read
    user_id_select = datareader("userid")
End While

BUT because you already read the record, when you get to your loop the code will see that you have come to the end of your datareader records and not enter into the loop.

I think what you wanted to do was something like this:

If datareader.HasRows then
    while datareader.read
        user_id_select = datareader("userid")
    End while
End if

OR:

If datareader.hasrows then
    datareader.read
    user_id_select = datareader("userid")
end if
G_Waddell 131 Posting Whiz in Training

Hi,

I see you adding to the datagridview and I see you inserting via your insert command - are you getting an issue or something?

G_Waddell 131 Posting Whiz in Training

this method will return the contents of a specific field in the curtrent record

This is in a comment on one of the functions in "your" class I suggest starting here...

G_Waddell 131 Posting Whiz in Training

Hi
Are you using a common networked database for all users? Or is it that you are deploying the database with the program i.e. one database per user?

Begginnerdev commented: Forgot to ask! :) +8
G_Waddell 131 Posting Whiz in Training

Hi,

You have not supplied a WHERE clause in your SQL and it looks like you have mixed up the syntax between an INSERT statement and the DELETE Statement.

With Insert Statements, you are creating new records so you pass in the table columns and the values.

With DELETE, SELECT and UPDATE statements you either apply to the whole table or you add a WHERE clause to apply to a subset of the data. i.e. If I run DELETE FROM MyUserTable - I have deleted every record from MyUserTable if I run DELETE FROM MyUserTable WHERE (UserID = 5) then I have only deleted the records where the UserID column has a value of 5.

If you carry out a SQL Delete command , you are deleting the record so you do not specify the columns.

If however, you want to "delete" the values in certain record(s) for specific columns then you would apply a SQL Update command i.e. UPDATE MyUserTable SET Title='' WHERE (UserID =5) would "blank" the title column of any record where the UserID column equals 5.

G_Waddell 131 Posting Whiz in Training

I know this thread is inactive BUT VB.net has a built in text parser for handling delimited files such as CSV: MSDN: Read CSV File Content

G_Waddell 131 Posting Whiz in Training

Hi
your databinding is wrong, the dataset will contain a table with the data retrieved from the query run in your data adapter. (The idea is that you can store several different query results in a single dataset and even link them with relationships - think of it as a local database)

In fact you did have the datagrid binding to the correct datatable at the end of your second post:

dgvPartDescription.DataSource = ds.Tables(0)

You may have just needed to refresh it....

dgvPartDescription.Refresh
G_Waddell 131 Posting Whiz in Training

Hi Guys,

I have invoked the 80:20 rule and decided to set showplusminus to false as I just don't have the time just now.

Begginnerdev commented: If only we humans can impelement time slicing... :) +0
G_Waddell 131 Posting Whiz in Training

Hi All,
I have a problem with a treeview class in my windows form. Specifically I'm try to detect when a user has expanded or contracted a node verses if they have clicked/selected the actual node.

When the user clicks on the node, I want to expand / contract the node to Hide / Show the child nodes (if there are any,) and if there is an associated action trigger it.
So my code goes like this:

Sub SideMenu_MouseClick(sender as Object, e as System.Windows.Forms.TreeNodeMouseClickEventArgs ) Handles SideMenu.MouseClick
    Dim MyNode As TreeViewNode = e.Node
    'here is where the problem occurs
    if myNode.IsExpanded then
        myNode.Collapse
    else
        myNode.Expand
    end if

    Select case trim(MyNode.Keycode)
        'Here is where I react to "action" nodes i.e. nodes that trigger actions    
    End Select

End Sub

Which works until the user clicks on the +/- box next to a node that has child nodes - The control seams to automatically expand the node then it enters my event code and recollapses or reexpands the node!!

i.e. node 1 is in an unexpanded state the user clicks the expansion button which expands it, then the MouseClick event fires sees that it is already expanded and collapses it.

I've been trying to see if there is a way to capture the button expansion but so far I can only see it happening on MouseClick - Nothing on BeforeSelect, AfterSelect etc. Mouseclick also does not seam to expose the treeviewaction to me to catch if it is Collapse …

Begginnerdev commented: Looks like I was 50 seconds to slow! :D +8
G_Waddell 131 Posting Whiz in Training

Sorry,
but a web based application and a desktop application are two different things. Do you mean you want the clients to be able to install the application from a web site? or do you mean create a web enabled / web based version of your application?

G_Waddell 131 Posting Whiz in Training

Hi,

You'll want to look at relation databases and design - quite a subject in it own right but in a nut shell: Suppose you have a table of doctors, a table patients and a table of visits.

Your doctor table contains all the data on your doctors but what if for example, you have two doctors named "John Smith" so you put a column in the doctor table that will uniquely identify each doctors record lets call it doctorID (as your using SQL Server make it an integer and enable Identity on the field,) now for each new doctor record entered the table will automatically populate the doctorID field with the next number in sequence. You can now mark this field as a PRIMARY KEY as it will be unique to each doctor i.e. there will be only one record with a DoctorID of 1.

Now for your patients you would do the same thing, except we'll call it PatientNumber. So You have two tables Patient and Doctor both with Primary Keys.

Now Patients Visit doctors and doctors take visits so your Visit table will link each patient and doctor to the history of the visit. First of all give Visit a primary Key just like you did to the others (VisitNumber?) Then you want to link the visit to the doctor - so you need a field in the visit table that links to the correct Doctor.... Now what do we have in the Doctors table that is …

G_Waddell 131 Posting Whiz in Training

Hi,

I haven't a clue where to start on that one, maybe you should post under the Hardware & Software forum - it sound like the issue you have is hardware related i.e. how do you read which pin is live

G_Waddell 131 Posting Whiz in Training

Hi,

Your form Action is set to handler.asp this means the form submits to the page handler.asp for processing.

In the Handler page you do something like this:

<%
    'as your using classic ASP your radio button can all be called the same thing:
    dim myURL as string =""
    Select Case Request.Form("Subject")
        case "ten"
            myURL = "/tenpage.asp" 'where ever you go if this value is selected
        case "five"
            myURL ="/fivepage.asp"  
        case else 'three
            myURL ="/threepage.asp"
    End Select
    Reponse.redirect myURL

%>  
G_Waddell 131 Posting Whiz in Training

Hmmm...
I once did a fairly good bar chart using html tables and coloured table cells.
I made a borderless table containing rows of twenty cells (each cell = 5%) (I didn't have to be too accurate)
Then for each thing I was displaying I calculated the percentage of the total, picked a colour and set the background colour of the appropriate number of cells to the colour. i.e. suppose item one had a value of 50% I picked a colour (I think I used an array of colours and went through the array assigning them) then for the row I was generating for that item I calculated how many cells to colour 50/5 = 10 the HTML I generated for the row was something like this:

<tr>
    <td colspan="10" style="background-color:red;">&nbsp;</td>
    <td colspan="10" style="background-color:white;">Myitem(50%)</td>
</tr>

Then I put an extra row in as a key with a top and right border and right aligned text so you had 5%, 10%, 15% etc

G_Waddell 131 Posting Whiz in Training

Another tip, you will wish to avoid SQL Injection Attacks where a user enters a damaging piece of SQL into an input that is then run on your SQL database as the input is processed by SQL Server.

  • Try to use and run stored procedures with parameters on the database rather than building queries on the fly
  • If you have to build a query on the fly, then use parameters
  • Connect to the database via a single SQL user that only has permission to execute the stored procedures you will be running.
  • Try and stop the damage in the first place by limiting input into textboxes etc i.e. maximum lengths, filtering input.
G_Waddell 131 Posting Whiz in Training

Hi,
For retrieving Data from your database:
SQLDataAdaptor
SQLDataReader

For running commands on the database such as Inserts and Updates:
SQLCommand

For Connecting to a database:
Connectionstrings.com

G_Waddell 131 Posting Whiz in Training

Show us what code you have so far and where it is falling over/ you are stuck...

G_Waddell 131 Posting Whiz in Training

First are you sure there is definately a table named Personal_Details in your database?

If so try using [Personal_Details] instead of just Personal_Details access may not like the table name not being bracketed off.

Also, (because I know others will point this out,) it is a bit of a security risk not to use parameterised queries when building your SQL string - you run the risk of a SQL injection attack.

G_Waddell 131 Posting Whiz in Training

No worries

G_Waddell 131 Posting Whiz in Training

Funny thing is this next round of matches it could all change again...

Scotland are still in the hunt for Second place even though we all admit our team still needs major improvement / work

G_Waddell 131 Posting Whiz in Training

Hi,
You should just in case also convert your search string to lower to ensure both the search string and the string being searched are in the same case.

Why not use Instr?

IF Instr(StringToSearch, lcase(trim(Textbox1.Text))) <> 0 Then
G_Waddell 131 Posting Whiz in Training

Hi,

Have you tried running in debug and doing watches on newpass and passwordchange?

Maybe newpassword1.text is empty?

Also how are you running the passwordchange query through a sql command? could you show us the code where yu execute the query?

G_Waddell 131 Posting Whiz in Training

You added "ON DELETE CASCADE" to your statement. You should remove this from the Customer_Sample table and apply it to the Sample table.

G_Waddell 131 Posting Whiz in Training

Do a search for the following (both Google and here):

Dataadaptor
Datareader
SQL

G_Waddell 131 Posting Whiz in Training

Hi,

Try this then:
cmd.Parameters.AddWithValue("@Empid", Cint(Trim(TxtEmpID.Text)))

G_Waddell 131 Posting Whiz in Training

Hi,

Run the code in debug mode and find the exact line that gives the error.. That's alot of code to go through!

I'd say it is likely to be somewhere you are running a SELECT statement based on a WHERE clause and an empty or null value is being passed in e.g.

sql="SELECT * FROM MyTable WHERE (ID =" & MyID &")"

but the MyID value is not populated.

G_Waddell 131 Posting Whiz in Training

Hi,

Can you post the code you have so far? I'd also google and run a search on this very forum - they have loads of examples and queries on here about datagridviews

G_Waddell 131 Posting Whiz in Training

Hi,
Could you post what you have so far? What you want to do is to select the last record entered into the text box for that person hint: sort your query by person and date or record id in descending order.

G_Waddell 131 Posting Whiz in Training

Hi,
Instead of cmd.Parameters.AddWithValue("@Empid", TxtEmpID.Text.Trim.ToString) I think you meant cmd.Parameters.AddWithValue("@Empid", Trim(TxtEmpID.Text))

You may also want to check that there is actually a value in the textbox first.

G_Waddell 131 Posting Whiz in Training

If Random guys can just show up take your dll and decompile it then a login page is the least of your security issues on that server! If you're that worried you can use an obfuscation program. But frankly if you have a secure server they shouldn't be able to even get to that stage. What if they get in and hijack your session? or use cross site scripting? You are only as secure as the system you design and build on. ASP.NET is just as secure as PHP

G_Waddell 131 Posting Whiz in Training

So you're saying an uncomplied php file is more secure than a complied .Net program?

G_Waddell 131 Posting Whiz in Training

Hi

Why use PHP? Why not VB.NET > MySQL?