|
i'm using the find method of DataView to search for students using the student's id or student's last name, i have no problems using the student's id for search. my only problem is, when i search using the student's last name it seems that it is not working sometimes it will display the wrong student for example i'll put "Cross" as my student's last name then it will search and display "Mason". how can i resolve this?, is there something wrong with my code.
Private Sub btnGo_Click(ByVal sender As System.Object, ByVal e As_ System.EventArgs) Handles btnGo.Click
Dim i As Integer
Dim StudDV As Data.DataView = New Data.DataView(Dsstudent.student,_ "", "StudID", Data.DataViewRowState.CurrentRows)
Dim StudDV1 As Data.DataView = New Data.DataView(Dsstudent.student,_ "", "StudLastName", Data.DataViewRowState.CurrentRows)
If cboFind.Text = "Student ID" Then
i = StudDV.Find(txtSearch.Text)
ElseIf cboFind.Text = "Student Name" Then
i = StudDV1.Find(txtSearch.Text)
End If
StudentBindingSource.Position = i
End Sub
by the way i am using access database and have 2 indexes the student id as my primary key and last name as my second index.
thanks in advance
|
|
|
|
|
hellow to all
i am trying to run a code that access a DB find a value that was entered by user ..
for this code i am useing sql statments , but when i run the code i recive this error msg
No value given for one or more required parameters .
i had cheaked the code trillion time and the db connection is fine !
if any one have any idea how can i run an sql statment in vb.net to find a value please help ! , because when i run a regular select statment it show's to me the tabel fine but when i user the where statment ,i get errors .
here is the code
Dim sql As String
sql = "select * from Customer Where Customer_ID ="
Dim objconn As New OleDb.OleDbConnection(sConnection)
Dim objdataadapter As New OleDb.OleDbDataAdapter(sql & TextBox1.Text, objconn)
Dim objds As New DataSet("Customer")
Dim objdv As DataView
Dim objtabel As DataTable
Dim ds As DataSet
ds = New DataSet("Customer")
Try
objconn.Open()
Catch ex As Exception
Windows.Forms.MessageBox.Show(ex.Message)
End Try
If objconn.State = ConnectionState.Open Then
Try
objdataadapter.Fill(ds, "Customer")
objtabel = objds.Tables("Customer")
objdv = objtabel.DefaultView
DataGrid1.SetDataBinding(ds, "Customer")
' TextBox2.DataBindings.Add("text", ds, "Customer")
Catch ex As Exception
Windows.Forms.MessageBox.Show(ex.Message)
End Try
End If
End Sub
|
|
|
|
|
microuser_2000 wrote:
but when i run the code i recive this error msg
No value given for one or more required parameters .
So, where do you receive this error message? What line of the code generates it.
Also you should be aware that your code is highly susceptable to a SQL Injection attack. You are injecting the text value of TextBox1 directly into the SQL statement. What happens if the value in TextBox1 is blank? You SQL statement is incomplete. What happens if someone types the following into TextBox1:
0; DELETE Customers;-- What happens is that your full SQL Statement will look like this:
select * from Customer Where Customer_ID = 0; DELETE Customers;-- Which will go ahead and delete everything in your Customers table.
You might find the following article useful: SQL Injection Attacks and Some Tips on How to Prevent Them[^]
My: Blog | Photos | Next SQL Presentation
WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
|
|
|
|
|
when i run the code i use IO Exception to generat the erros so i get this error as a messagebox and i do not get line of error ..
i know that it is not securie to run code like mine , but i will use a function the will filter input to textbox ...
but what i am looking for now is how to write a code that can pick a value from db !!!
thxx for ur help ...
|
|
|
|
|
Have you considered setting breakpoints and stepping through the code to find out where the exception is being thrown. You also get to see the state of variables as they are changed and so on.
Anonymous wrote:
i know that it is not securie to run code like mine , but i will use a function the will filter input to textbox ...
How good will your filtering be? Even although I filter the results of text boxes before passing them to database queries I still use parameters to pass the data to the database in order that, should I have missed something, the framework will protect me. At the very least I do my best to ensure that my application will fail safe. The idea is that you do everything you can to reduce the attack surface of your application.
My: Blog | Photos | Next SQL Presentation
WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
|
|
|
|
|
i have a usercontrol made at design time. i want to load it on a form at runtime. can anyone help please
If i am adding that control at designtime its working fine. but i want to add it runtime.
|
|
|
|
|
At the click event or whatever :
Dim con = new myUserControl
with
.Location = new Point()
//and so on.
|
|
|
|
|
i have the similar problem except i want to the usercontrol develop in vb6.
when i user : dim ctrl as new myUserControl it give an error message as belows >>> myUserControl.Private Sub New()' is not accessible in this context because it is 'Private'. <<<
so how i want to define the 'Public Sub New()' in vb6.. it give error.
|
|
|
|
|
All you have to do is instantiate your control and add it to the form's Controls collection:
Dim newControl As New MyCustomControl
newControl.Top = whatever
newControl.Left = whatever
... set your controls properties here
' and to make it show up on the form:
Me.Controls.Add(newControl)
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Actualy i cannot create a instance of my control .i donot know why but it doesn't give me option like dim ctrl as new mycontrol. its not showing in the options after new .That control is in my project at desgin time. i donot know what do do. its all in visual basic 6
|
|
|
|
|
Did you have this project reference your control project? It's been a long time since I've used VB6, but I think you should be looking under the Project menu, References. From there, you can pick your user control's .DLL file to set a reference to it, then you should be able to create an instance of your control.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
yes i have refernced that control (project in my refrence) if i add it from componnets it appears in the toolbox. but i cannot create a runtime object with it .
|
|
|
|
|
Just like when you Start->Turn off Computer
It nicely gray's out the desktop except for the
"turn off computer" dialog box that prompts you for
standby, turn off, reset.
Any ideas on how to do this programmatically
in vb.net?
Thanks,
Tom
|
|
|
|
|
this may be a bit of a workaround, but maybe it can help you in the right direction...
you can have a background form (topmost though) that slowly fades in (opacity from 0 to 1)
the background of that form can be a screenshot of the desktop (check Bob Powell's: Capturing the screen or the surface of a control
and on top of that a new form with what you want to show
hope this can help u out
|
|
|
|
|
Terrific suggestion - I'll give that a shot and report back, thanks mate!
|
|
|
|
|
Hi all,,
I used to use the ICT (internet transfer control) in Vb 6 when i need to transfer a data to web page that request data through the URL i.e "\\webserver\getdata.asp?name?sex"
i'm using the vb.net now but this component is not avalible
so does any body know how to do this in vb.net..!??!
any peice of code or clear good referece as quick as possible will be helpfull..
i appreciate ur coorprate guys..
thx
Hani
|
|
|
|
|
Search the articles for "HttpWebRequest" and you'll find what you're looking for.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Can someone please help me with how I would code a simple chat program to run over a network.
I have designed the forms which have chat windows etc. but am lost on how to make it communicate from client to client.
I have looked at DDE in the help files but found it hard to understande. I am only new to visual basic. I am 16 years old and keen to get into program, this is my first program.
Is there anyone that can help to steer me in the right direction.
Cheers John
Posted by The ANZAC
|
|
|
|
|
|
First program?! You better start with something a little simpler. It would be wise to learn how Windows forms controls work before venturing off into networking...
Just my opinion...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
ive got a book called 'visual basic .net power tools'
in chapter 12 the book explains how to make a chat program
ive never read the chapter, but you can download the source code from Sybex at this link
as i sead, somewhere in chapter 12
hope this sample can help you on the way!
ps: i'm 16 too! i never knew there were more young programmers out there, but appareantly they are!
have fun!
|
|
|
|
|
|
Late starter?!? never said i started at 16! i mastered C before i could walk man!:->
just kiddin LOL
|
|
|
|
|
|
Hi
I am creating a tree view control dynamically and all the nodes and child nodes of that tree view are being read from an xml file. Now I have two buttons "Move Up" and "Move Down". On click of these buttons I should be able to navigate through the nodes and child nodes. How can i set the focus to the previous node and next node?The Applicaton is a simple Windows based and I am using VB.Net.
Any help would be highly appreciated.
Thanks
Qot
|
|
|
|