.Net Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - More.Net Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 22nd, 2003, 04:21 PM
Digee Digee is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 2 Digee User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Searching Datatype Error

I'm setting up a form that does search and pulls in the info into a datagrid. The way i have it set up now is that it only searches one column. But I need it to search four different columns.

My Connnection:

Public Function TFGetRecords(ByVal TOLLFREE As String)

' Create Instance of Connection and Command Object
Dim myConnection As New SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))

' Generate Command Object based on Method
Dim myCommand As SqlCommand = SqlCommandGenerator.GenerateCommand(myConnection, _
CType(MethodBase.GetCurrentMethod(), MethodInfo), _
New Object() {TOLLFREE})

' Execute the command
myConnection.Open()
Dim result As SqlDataReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection)

' Return the datareader=20
Return result

End Function


My code:

Sub BindSearch(ByVal SearchString As String)
Dim ds As New DataSet()
ds = ConvertDataReaderToDataSet(_TollFreeDB.TFGetRecords(SearchString))

dgRecords.DataSource = ds
dgRecords.DataBind()
ds.Dispose()
End Sub

Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click
dgRecords.Visible = True
BindRecordSearch()
BindSearch(txtRecordSearch.Text)


End Sub

my stored procedure is really long, so i'll shorten it:

CREATE PROCEDURE dbo.TFGetRecords

@TollFree float

as
select column from table where WHERE (TollFreeNumber LIKE '%' + Convert(nvarchar,@TollFree) + '%')

If you want to see the whole thing, please let me know.

Thank you in advance!


ps. someone suggested that i set up my where like this:

WHERE (TollFreeNumber LIKE '%' + Convert(nvarchar,@TollFree) + '%') OR
(OtherColumn LIKE '%' + Convert(nvarchar,@TollFree) + '%') OR
(OtherColumn LIKE '%' + Convert(nvarchar,@TollFree) + '%')


but when I did I got an error of: SqlException: Error converting data type nvarchar to float.]

however, I don't have any control of what the datatypes are.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - More.Net Development > Searching Datatype Error


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT