Smith5646 24 Junior Poster in Training

I am totally lost on this and not sure how to help further. Did you try the other suggestions that I made earlier? What were the results (reply using the question numbers)?

Syntax in the below code will probably need tweeked because I am free typing and not using Studio to edit / verify.

1) Write a block of code to retrieve all rows from the DB and see if the row in question shows up that way.

Dim cmd As New SqlClient.SqlCommand("SELECT * FROM tbl_user", con)
cmd.Connection.Open()
Dim reader As SqlClient.SqlDataReader = cmd.ExecuteReader()
while reader.HasRows
  messagebox.show(reader(1))
end while

2) Do a "select count(*) from tbl_user" to see how many rows it thinks are in the DB.

Dim cmd As New SqlClient.SqlCommand("SELECT count(*) FROM tbl_user", con)
cmd.Connection.Open()
Dim reader As SqlClient.SqlDataReader = cmd.ExecuteReader()
messagebox.show(reader(0))

3) See if the values in the DB have extra spaces or something at the end of them.
Try changing you inserts to be .TEXT.TRIM

4) See if the values in your textboxes have extra spaces or something at the end of them.
Try changing you selects to be .TEXT.TRIM

5) If you have another way to access your DB, see if it returns the row. For example, in visual studio you can "show table data".

Smith5646 24 Junior Poster in Training

I just want an exported copy of the data that I can read. I can't open a .MDF.

Smith5646 24 Junior Poster in Training

I didn't realize the .MDF is SQL server (should have looked at the connection statement closer). Right now I don't have access to a machine with SQL server. Can you export to something such as Access, Excel, .csv?

Smith5646 24 Junior Poster in Training

I'm totally confused now. Can you attach the .MDF file to this thread so I can look at it?

Smith5646 24 Junior Poster in Training

This has me baffled so bear with me for some stupid questions.

If you have 3 records in the DB and then add a 4th record, you say it does not find the 4th record.

If you exit the app and restart, does it find the 4th record?

If you add a 4th and 5th record, does it find the 4th record but not the 5th or does it not find either?

Smith5646 24 Junior Poster in Training

Now I understand the issue but really don't have a good answer. The code in lines 2 - 17 look right to me.

I am assuming they type into txtUser and txtPass and then click OK which sends them into this sub.

I'm not sure what you are doing with lines 23 and 34 and if they are causing you problems somehow. I doubt it but thought it was worth mentioning.

Here are a couple things to try.
1) Write a quick block of code to retrieve all rows from the DB and see if the row in question shows up that way. You can also do a "select count(*) from tbl_user" to see how many rows it thinks are in the DB. If these work, it has to be something in the select.
2) See if the values in the DB have extra spaces or something at the end of them.
3) See if the values in your textboxes have extra spaces or something at the end of them.
4) If you have another way to access your DB, try doing the select command outside of your program to see if it returns the row.

Let me know what you find and we'll keep narrowing it down.

Smith5646 24 Junior Poster in Training

What is the problem? Is the program blowing up? Is it not returning rows? Is it returning wrong rows?

Smith5646 24 Junior Poster in Training

You are missing some &s for joining strings. "" such as "string1""string2" is translated as string1"string2 and not string1string2

Public urlMySQLDatabase1 As String = "Server=" & frmLogin.txtServerIP.Text & ";" _
        & "Port=" & frmLogin.txtServerPort.Text & ";" _
        & "Database=DatabaseName" & ";" _
        & "Uid=UserID" & ";" _
        & "Pwd=Password" & ";"
Smith5646 24 Junior Poster in Training

One other comment. Since you initialize the .SelectedValue to 0, this works as expected.

Be aware that if you do not initialize it, the value is -1 and trying to retrieve the text when ComboBox.SelectedValue = -1 will blow up.

Smith5646 24 Junior Poster in Training

Line 28 should be cboStreetName1.Text. .selectedindex.tostring returns the number of the selected index. As a debugging hint, I often use MessageBox.Show to make sure I am getting the value that I am expecting as in MessageBox.Show(cboStreetName1.SelectedIndex.ToString)

I am assuming that you are wrapping lines 22-33 in a SelectedIndexChanged block so it will load the proper values when they select a different street.

Smith5646 24 Junior Poster in Training

Maybe you could use an arraylist (drivers in the example below) instead of 6 different variables (d1 - d6). Then you could do something like this.

If player(x).drivers.Contains("VETTEL") Then
  player(x).score += score.vettel
End If
codeorder commented: quite helpful:) +12
Smith5646 24 Junior Poster in Training

I'm confused with what you are expecting to see. Do you want the two textboxes to look the same without the first and last line or do you want it in a single line with a space between each value like this...

sadsadasdas dsad as das d

Either way, I think your problem is that lines 19 and 21 are identical. I'm guessing line 21 should include a vbnewline or a space.

TextBox2.Text &= vbnewline & line

or

TextBox2.Text &= " " & line

Smith5646 24 Junior Poster in Training

The below code will trap the event you are after. However, once an item is selected, it can't be deselected without selecting another value. In other words, SelectedIndex will never again = -1. It would seem that you need to set Label26.visible = true during load and then let this function turn it off after the user selects a value.

Private Sub ComboType_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboType.SelectedIndexChanged
        If ComboType.SelectedIndex = -1 Then
            Label26.Visible = True
            Label26.ForeColor = Color.Red
            Label26.Text = "(Select the Job Category )"
        Else
            Label26.Visible = False
        End If
    End Sub
b1izzard commented: Good +2
Smith5646 24 Junior Poster in Training

Remember that a "do while" loop executes the logic inside the loop and then executes the while. In your case, you are trying to do an rs.getString(1) but have never done the rs.next to load the values.

Your code should look like this

<%
while(rs.next)
{
      user = rs.getString(1);
      pass = rs.getString(2);
      typ = rs.getString(3);
%>
pnt = user + " " +pass+" "+typ;
%>
<p> <%=pnt%> </p>
<%
}; <== Not sure if you need the ";".  I forget the syntax for the end of a while loop.
%>

If this still blows up, please repost your code and tell exactly what line is blowing up.

Smith5646 24 Junior Poster in Training

It has been a while so I could be remembering this incorrectly.

I believe you need to do your rs.next() before your rs.getstring(). The execute query does not retrieve any data from the database, only prepares it for the first rs.next(). By having a do...while, your while is not executed until the end of the do loop.

Try changing your
do
{
}while rs.next()
to
while rs.next()
{
}

Let me know if that doesn't fix the problem.

Smith5646 24 Junior Poster in Training

Your SQL statement is messed up. Where clauses need "AND"s between comparisons, not commas.

'12345' = CustomerID AND 'Smith' = Surname

Run this in the debugger and break on line 130 (based on the above code) and look at SQLString. Also, before you have problems with it later, your SQLString built in line 82 is wrong too. Select where clauses also need "AND"s between comparisons, not commas.

Smith5646 24 Junior Poster in Training

I'm not sure from your post if you still have questions. One thing that looks like you may still be confused is the .dispose and .add. .dispose deletes the control from your program and frees the memory. The only way to do the .add is to recreate the control.

If you still have questions, post a little more detail about your program. Are you manually creating and adding controls to your forms or are they controls created via drag and drop using the GUI? Why are you trying to take them off of the form?

What do mean by "does not load"?
Control Events > Load. Since you told me that .remove does not delete the control, more than enough answer for me.

-----

Whenever I .Add a control after I .Dispose it, I receive a message "can't access a disposed object"

My program deletes a control and adds it again. I don't want to use .Remove because it requires me to manually reload all variables.

Smith5646 24 Junior Poster in Training

.Remove does not delete or alter the control, it just takes it off of Form1.
.Dispose removes the control from Form1 and deletes it.
.Add adds the control to Form1 AS IS.

I'm not sure what you mean by "does not load" and what variables are not reloaded. Give me a little more detail on that part and I will try to point you in the right direction.

Can anyone tell my why the code...

Form1.Controls.Remove(myCustomControl)

...does not remove the control.

Because whenever I remove a control and add it again, it does not Load but rather just changes its visibility from false to true and all the variables are not reloaded.

I tried to use .Dispose() but VB.net tells me that it can't access a disposed object whenever I try to add the control again.

Any better methods?

Smith5646 24 Junior Poster in Training

Since rd.read() will return a true if the read was successful and false if it was not, try...

If rd.read() Then
    If TextBox8.Text = rd(0) Then
    ...remainder of your code
    End If
Else
    MsgBox("BAD Username")
End If