Question on building a Search web form

Hello everyone, how are you doing? I am just begining using ASP.Net for our Intranet. I know some but still learning. What I have done so far is I have data.vb object that is connecting to my database and has my dataset. Now I am in my web form and I have three text boxes that I want the user to enter the First name, last name, and date of birth. Then hit search. And I have a datalist that will return and display the rows that match the criteria the users entered. Now where I am trobuling is when the user hits the search button and the event is activated what should the code be?? In my select datAdapter I have the where statment pulling data where the Ch_last_Name = @LastName. Is that correct. Is the @LastName going to be used to match the text entered? Thanks for any help. :)

Who is Participating?
NauticalNonsenseConnect With a Mentor Commented:
Happy that worked for ya!

You may have to ask another question for that one, i found this googling.

Dim strConnString As String = "Driver=

"DRIVER={SQL Server};SERVER=MyServer;UID=sa;PWD=Qvr&77xk;DATABASE=northwind;"
Not sure if I understand your question. Are you having trouble getting the form values?

<asp:TextBox id=tbLastName runat=server />

Dim sLastName as String
sLastName = tbLastName.Text

And then either build your query, or when you assign your SQL parameters, just use sLastname to feed that.

D_bashamAuthor Commented:
I thought it might be confusing. What I am having trobule with is if I have my datadabter sql code right with is:
WHERE     (CH_PT_LAST_NAME = '@LastName')

Then when user enteres the last name in my web form and hits the search button what should my code look like besides what I have now:

 Dim dsDataSet1 As DataSet  'Variable to hold the dataset
            Dim objData As New Data     'Instance of the data tier class

            dsDataSet1 = objData.getData    'Retrieve the dataset
            Session("Dataset") = dsDataSet1   'Save the dataset in a session variable
            dlPatAdm.DataSource = dsDataSet1    'Set the grid's DataSource to the new dataset
            Me.DataBind()     'Bind the dataset to the grid

Thanks for help.
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Is this what you're trying to accomplish?

Dim sLastName As String
sLastName = tbLastName.Text

Dim ds As New DataSet()
Dim conn As New SqlConnection(System.Configuration.ConfigurationSettings.AppSettings("YourConnectionString"))
Dim cmd As New SqlCommand()
cmd.Connection = conn
cmd.CommandText = "YourStoredProcedureName"
cmd.Parameters.Add("@lastname", sLastName)
cmd.CommandType = CommandType.StoredProcedure
Dim daTop As New SqlDataAdapter(cmd)
daTop.Fill(ds, "YourTable")
dgDataGrid.DataSource = ds.Tables("YourTable").DefaultView
D_bashamAuthor Commented:
Thanks for the help that worked. Now I have another qustion on my form I am using an ODBC connection to go to the database. But the form is trying to use ASPNET user name to access the ODBC open connection. My username is the only one that has access to that ODBC driver and database how do I change the username to be me trying to open the oDBC not ASPNET? Thanks. I

D_bashamAuthor Commented:
This is my connection string DSN=Allegra;UID=csmith;NODE=;PWD=kdjlkdj;APPLICATION=RMS

But when I try to search I get this error.

ERROR [08001] Unable to find CDD. File not found. (P:\CDD\FILE.cdd) Win32 Error(3) UserName=(CSMITH2\ASPNET)

 I havew been searching to on google and that connection string is what I did but as you can ssee the username is ASPNET. What I am I doing wrong in my web.config file?
That's got nothing to do with the database connection, that's a different problem that the application is encountering, running under the context of ASPNET. I don't know what CDD is, but that's an entirely different problem.

Cheers, aaron
Hope you found your CDD problem. Can you close this question out?
D_bashamAuthor Commented:
Thanks for all the help :)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.