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. :)

Db
D_bashamAsked:
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.

MYSQL
Dim strConnString As String = "Driver=
{mySQL};Server=YourServer;option=16834;Database=YourDataBas
e;Uid=UserName;Pwd=Password;"

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

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

VB
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.

0
 
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:
SELECT     CH_PT_LAST_NAME, CH_PT_FIRST_NAME, CH_MRN_KEY, CH_HSP_SVC
FROM         PDRACCMAS_REC
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.
0
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.

 
NauticalNonsenseCommented:
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
conn.Open()
Dim daTop As New SqlDataAdapter(cmd)
daTop.Fill(ds, "YourTable")
dgDataGrid.DataSource = ds.Tables("YourTable").DefaultView
dgDataGrid.DataBind()
0
 
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

0
 
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?
0
 
NauticalNonsenseCommented:
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
0
 
NauticalNonsenseCommented:
Hope you found your CDD problem. Can you close this question out?
0
 
D_bashamAuthor Commented:
Thanks for all the help :)
0
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.