I am tryin to input an ID number and retrieve all the information from that particualr ID
Private Sub btnSubmit_Click(Byval sender As System.Object By val e As System.EventArgs)Handles Button1.Click
connClass.Open()
Dim cmdStudents As New OleDb.Command
Dim sStudents As String = Select Student Name, Information From ClassName Where Student ID =
cmdStudents.CommandText = sStudents
daStudents.SelectCommand = cmdStudents
Dim cbStudents AS New OleDb.CommandBuilder()
cbStudents.DataAdapter = daStudents
Here is where i run into the problem
Dim ol As New olet2() 'This is my other form with a textbox1
If textbox1.Text <> "" Then daStudents.SelectCommand.Paramerters(" ").Value =
ol.Textbox1.Text
I just want the value that represents that Student ID to be visible in the textbox on the other form but for some reason when i enter the student ID nothing happens.....any help would be great!

how to show string of data in text box using parmeter query
Furrukh Baig
Hi, Tryin,
Seems to me that after 8 replies, you have no answer to your question yet.
The answer is in the fact that all control inside a Form are scoped as Friend and not Public.
Eventhough Form ol is declared in your current Form, its controls are not accessible from outside that parent Form olet2.
Declaring the textbox1 in olet2 as Public is NOT a good idea or a good pratice. Don't try it. You want your code to look professional.
To solve the issue, create a Public property in the Form olet2. As simple as:
Public ReadOnly Property StudentID() as String
Get
Return Textbox1.Text
End Get
End Property
This should solve your issue. Good Luck!
NealHo
A property is essentially a method (or set of methods) that are used in code like fields. For example, for your above StudentID property, the first of the following statements essentially translates to the second:
Dim id As String = Me.StudentID
Dim id As String = Me.get_StudentID()
In fact, that is essentially how properties are compiled in the IL.
If the property wasnt readonly (i.e. if it had a Set block), then you call also write the following first statement, which would be equivalent to the second:
Me.StudentID = id
Me.set_StudentID(id)
Visual Basic has had this capability for a while, but in C++ you had to resort to paired Get/Set methods. Properties are a way to encapsulate these paired methods and make their usage more intuitive.
Eugene Ostroukhov
Sue Googe
Hello my friend!
First of all you didn't tell what error message you are getting, becuase as I can see there are many problems with your code.
You query has columns with white spaces which is not allowed in sql query. If at all your table contains columns names with space then enclose them in square brackets in the SQL query. Another problem is that this question mark is place holder not a parameter name. So when you are adding parameter you should specify the column name with which you are comparing it prefixed by @ in your case it should be (@StudentID). Or you can use name parameters as follow:
Select * From yourtable Where StudentID = @StdID
daStudent.SelectCommand.Parameters.AddWithValue("@StdID,anyvalue);
You are not adding parameter to the parameters collections and try to assign value, this is what appears from code.
Thats it.
cheers
sputnikinternet
XAVY thank you!!! I understand properties but, i never knew it worked like that...Can you give me a quick not to technical explanantion of how Propertys work
Public ReadOnly Property StudentID() As String
Get
Return TextBox1.Text
End Get
End Property
Thats how the finish product should work right
WH Tan
CommonGenius.com why don't you try and see for your self. I'm very much talking about sql query passed through a provider can use named parameters with access.
Anyways since your post prompted me to test case this, therefore I owe to you for this and thankyou making me do this.
cheers.
octav
To try and clear up a little debate here...
You CAN use named parameters with MS Access, however, the names are irrelevant to Access....Access does not use the names of the parameters...it strictly fills the parameters by ordinal position. Access has always been that way and still is as of 2k3.
liquidweaver
Sorry for saying that you can't add question mark as a paramter which you can , but let me tell you can use named parameters with access as well and I checked that.
cheers
aurn
Try this out: If your result set returns a value of parameter @Id you then assign the value to textbox using Command object. ex: TextBox1.Text = cmd.Parameters("@Id").Value.ToString()
hth,
Michael Castillones
qqqqq
Yes you are rite
Cheers
timeshift