|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > .Net Development > Searching Datatype Error |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|