DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   ASP.NET (http://www.daniweb.com/forums/forum18.html)
-   -   How to Search record from the Sql Server Database (http://www.daniweb.com/forums/thread55249.html)

Dhruv Shah Sep 16th, 2006 2:31 pm
How to Search record from the Sql Server Database
 
i am developing a job site and i require to search for records from the database. i m passing value fro that parameter in textbox.
so please help me
thanks in advance

Paladine Sep 17th, 2006 12:23 pm
Re: How to Search record from the Sql Server Database
 
Quote:

Originally Posted by Dhruv Shah (Post 252950)
i am developing a job site and i require to search for records from the database. i m passing value fro that parameter in textbox.
so please help me
thanks in advance

pseudo_code:
Dim strSQL as String

strSQL = "SELECT Field1, Field2 FROM tbltemp WHERE Field1 = '" & TextBox1.Text & "'"

Hope this helps.

Dhruv Shah Sep 17th, 2006 1:46 pm
Re: How to Search record from the Sql Server Database
 
Quote:

Originally Posted by Paladine (Post 253223)
pseudo_code:
Dim strSQL as String
 
strSQL = "SELECT Field1, Field2 FROM tbltemp WHERE Field1 = '" & TextBox1.Text & "'"

Hope this helps.

thanks sir
this help me out. but when i m printing the record it also shows me textbox and command button. So sir now how do i remove this from print out.

Blah Blah Oct 3rd, 2006 12:16 am
Re: How to Search record from the Sql Server Database
 
Quote:

Originally Posted by Dhruv Shah (Post 252950)
i am developing a job site and i require to search for records from the database. i m passing value fro that parameter in textbox.
so please help me
thanks in advance

TRY THIS WITH ASP.NET USING VB.NET:

Private Sub btnsearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsearch.Click
Try
txtmsg.Text = ""
OleDbDataAdapter1 = New OleDbDataAdapter("select * from phbook where name like '" & ddl.SelectedItem.Text & "%'", OleDbConnection1)
OleDbDataAdapter1.Fill(DataSet21, "phbook")
OleDbConnection1.Open()
Dim com As New OleDbCommand
com.Connection = OleDbConnection1
com.CommandText = "select * from phbook"
dg1.DataBind()
Catch ex As Exception
txtmsg.Text = ex.ToString
OleDbConnection1.Close()
End Try
End Sub

THIS WILL SEARCH THE TEXT AND ONLY CHECKING THE FIRST LETTER OF THE GIVEN TEXT:

LIKE IF U WRITE "J" YHEN UT WILL SEARCH EVERY TEXT STARTING WITH THE LETTER J......

I HOPE THIS WILL HELP:cheesy:

ManicCW Oct 3rd, 2006 3:07 am
Re: How to Search record from the Sql Server Database
 
When passing query use parameters:
Quote:

cmd.CommandText = "SELECT ID, Title, Job FROM Jobs WHERE Title=@Title"
cmd.Parameters.Add("@Title", SqlDataType.NVarChar).Value = Me.txtTitle.Text.Trim
To hide some element while print:
http://www.daniweb.com/techtalkforums/thread54946.html

june_bunga Apr 4th, 2007 11:59 pm
Re: How to Search record from the Sql Server Database
 
Quote:

Originally Posted by Blah Blah (Post 259213)
TRY THIS WITH ASP.NET USING VB.NET:

Private Sub btnsearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsearch.Click
Try
txtmsg.Text = ""
OleDbDataAdapter1 = New OleDbDataAdapter("select * from phbook where name like '" & ddl.SelectedItem.Text & "%'", OleDbConnection1)
OleDbDataAdapter1.Fill(DataSet21, "phbook")
OleDbConnection1.Open()
Dim com As New OleDbCommand
com.Connection = OleDbConnection1
com.CommandText = "select * from phbook"
dg1.DataBind()
Catch ex As Exception
txtmsg.Text = ex.ToString
OleDbConnection1.Close()
End Try
End Sub

THIS WILL SEARCH THE TEXT AND ONLY CHECKING THE FIRST LETTER OF THE GIVEN TEXT:

LIKE IF U WRITE "J" YHEN UT WILL SEARCH EVERY TEXT STARTING WITH THE LETTER J......

I HOPE THIS WILL HELP:cheesy:


i try using this sample code to my application.but if you dont mind, can you state the namesapece of DATA declarations for connection n data type to match with this code.

tq

krany18 Nov 24th, 2008 1:31 am
Re: How to Search record from the Sql Server Database
 
please send me the c# sharp code ..
i am developing the application using the c# (same project i am doing like job portal)]
please send me ASAp


All times are GMT -4. The time now is 11:21 pm.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC