?
Solved

Question on building a Search web form

Posted on 2005-04-21
9
Medium Priority
?
246 Views
Last Modified: 2010-08-05
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
0
Comment
Question by:D_basham
  • 5
  • 4
9 Comments
 
LVL 7

Expert Comment

by:NauticalNonsense
ID: 13833817
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
 

Author Comment

by:D_basham
ID: 13833851
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
 
LVL 7

Expert Comment

by:NauticalNonsense
ID: 13835964
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:D_basham
ID: 13836100
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
 
LVL 7

Accepted Solution

by:
NauticalNonsense earned 760 total points
ID: 13836135
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
 

Author Comment

by:D_basham
ID: 13836178
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
 
LVL 7

Expert Comment

by:NauticalNonsense
ID: 13836300
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
 
LVL 7

Expert Comment

by:NauticalNonsense
ID: 13845121
Hope you found your CDD problem. Can you close this question out?
0
 

Author Comment

by:D_basham
ID: 13857605
Thanks for all the help :)
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question