Built In Function To Search The Occurence Of Char In String

Jan 10, 2008



Hi Everyone-
i woder if someone know Built in function to search the occurence of char in string in T-SQL

and iam not talking about the Index of the first occurence (e.g CHARINDEX )
but it is more generic

i want to send to the function to ask about the index the second or the third or N occurence of the char.
and i wonder if it is built in for performance reasons

example
getseachIndex("M|d|d","|",2)==> the result is 4

View 3 Replies


ADVERTISEMENT

Search Char In String

Jan 11, 2006

Hi

Is there any function to seperate a sting (VARCHAR) into two based on a character in the string (e.g. '-').

In short is there "InStr" or "split" type function in T-SQL ? If not what is the alternative?

I have a column called "Range" (VarChar) in the table which has ranges like 1-14 or 15-49 etc.

I need to select records by compare a variable (numeric) against these ranges.  

So for instace if the variable has 15 its in range 15-49.

I was thinking of spliting the range field into two so that comparison is possible.

Any suggestions?

thanks

 

 

 

View 5 Replies View Related

SQL Search String Function

Jun 2, 2008

The 'LIKE' function looks for words that start with whatever is in the like condition. Is there an sql function similar but will look and compare at any part of the search string.

For example I am using a webservice in dot net to populate a dropdown list using this sql

SELECT compound_name FROM dbo.compound_name WHERE compound_name like @prefixText

In this table there is a compound called SILCAP310 and I would like the search function to pick up 310 if I put this into the @prefix parameter. (but I would still like the search to perform like the 'LIKE' does also.

SELECT compound_name FROM dbo.compound_name WHERE compound_name like @prefixText or compound_name SearchPartString @prefixText

Thanks in advance

View 4 Replies View Related

String Occurence

Dec 2, 2003

Hi all,

Is there a function in SQL that will return the number of occurence of 1 string to the other.

e.g.

string1 = "1"
string2 = "2131145"

function should return 3

How do i obtain this in SQL?

Thanks in advance

View 9 Replies View Related

Counting The Occurence Of A String ...

Aug 27, 2006

Hi ...I have a weblog database where I want to count the occurences of atable of string values that appear in all the urls viewed.My tblWebLog as a field that contains the url ...tblWebLog.[cs-uri-stem]I have another table ... tblStrings ... that has a field [strSearch]for a string value and an integer field [intViewCount] to count theoccurence of the string in tblWebLog.[cs-uri-stem]I've been trying ...Update tblStringsSet [intViewCount] = (Select Count(*) From tblWebLog Where[cs-uri-stem] Like '%_' + tblStrings.[strSearch] + '.htm%').... but it doesn't fly and I'm stumped. Any thoughts?Cheers.

View 2 Replies View Related

Check The First Occurence Of A Numeric In A String

Mar 17, 2008



Hi All,
I want to extract a numeric value from a string. Example, in a string like - Mgmt Pack: Processor Exception Threshold >80% Every 10 Minutes. - I want to extract that number 80. Since, later I'll want this number to plot a graph.

Since this is going to be an alert pulled from OnePoint (MOM Operational Database), the number will vary, and so I cannot look for the same number. So, can anyone help me how to get this working?

Thanks a lot in advance and let me know if the question is not clear.

Manoj Deshpande.

View 4 Replies View Related

URGENT!!! Search Tool Function: Splitting A String

Jan 14, 2008

Hi All!!!
I was tasked to come up with a search function and the content of the database given to me is in Chinese Characters. This would be my first time dealing with Chinese characters in the database and I need help with the following problem:
The company wants to conduct the search in such a way that, instead of having the system read the entire sentence/phrase which the user keyed in as a SINGLE string, they want the Chinese Characters to be accessed individually, so that as long as any information in the database contains any one of the characters which the user have entered, they will be retrieved and returned.
So how do I go about doing this? Does it have anything to do with Unicode? By the way, everything abt the search tool is working fine, I am just left with this dilemma of having the system recognise the entire sentence as ONE STRING, instead of conducting a search word by word or character by character.
Anyway, the following is the SQL statement of my SQL Data Source which is bound to a Gridview displaying the returned results after a search is done...1 SELECT Name, Trans, Address1, Address1T, Address2, Address2T, City, CityT, CRPLID
2 FROM CRPL
3 WHERE (Trans LIKE '%' + @Trans + '%') OR
4 (Name LIKE '%' + @Name + '%') OR
5 (Address1 LIKE '%' + @Address1 + '%') OR
6 (Address1T LIKE '%' + @Address1T + '%') OR
7 (Address2 LIKE '%' + @Address2 + '%') OR
8 (Address2T LIKE '%' + @Address2T + '%') OR
9 (City LIKE '%' + @City + '%') OR
10 (CityT LIKE '%' + @CityT + '%')

 
Thanks for all your help in advance!!!

View 6 Replies View Related

Finding The Character Position Of Nth Occurence In A String.

Jun 15, 2001

Hi Friends:

I usually run this query in Oracle to find out the position of a character in a string from first position to the nth occurence.

For example, I run the following queries in oracle to get the desire result.

SQL> select instr('DADADAQQQA','A',1,1) FROM DUAL;

INSTR('DADADAQQQA','A',1,1) -- First occurence of 'A' from start.
---------------------------
2

SQL> select instr('DADADAQQQA','A',1,2) FROM DUAL;

INSTR('DADADAQQQA','A',1,2) -- Second occurence of 'A' from start.
---------------------------
4

SQL> select instr('DADADAQQQA','A',1,3) FROM DUAL;

INSTR('DADADAQQQA','A',1,3) -- Third occurence of 'A' from start.
---------------------------
6

SQL> select instr('DADADAQQQA','A',1,4) FROM DUAL;

INSTR('DADADAQQQA','A',1,4) -- Forth occurence of 'A' from start.
---------------------------
10


Is there ay equivelant way in Transact- SQL? If not, can anybody suggest the solution?


--Raj

View 4 Replies View Related

Help!!!!built In Function In Sql

Aug 15, 2007

Hi,
Is there some kind of built in function in SQl to look for the presence of certain characters in a table collumn.I have to replace the text in those collumns with different text or just use substr, instr functions.
Thanks in advance

View 4 Replies View Related

'INITCOLVS' Is Not A Recognized Built-in Function Name.

Nov 27, 2007

I have read all of the messages related to the above problem and none have solved the issue.
We have migrated a SQL 2000 database to SQL 2005.  Detached from one and attached to the other and then based on some of the conversation I also used the SQL Server 2005's copy option and copied the database.  Detached the old one and renamed the new database which was created in the copy process to the old name.  Basically getting back to where I started.  By the way there are no triggers generated during the process (as was mentioned), nothing to delete as some of the discussion was suggesting.  
Big databse, lots of tables and stored procedures.  All screens seem to work except when we try to update some data using a stored procedure which takes the data and updates the table.  End up getting the above error during the execution.  All used to work fine with SQL Server 2000.  I have taken the SQL out of the stored procedure and executed manually and it worked but leaving the stored procedure alone and calling it with the updated data we get the INITCOLVS problem.  The database is also set to be compatible to 90 so that suggestion also has not fixed the problem.  Looking for additional suggestions and solutions.  Some one was talking about making a dummy INITCOLVS function, have not done this yet but don't particularly like this suggestion, like to know the cause and the proper solution to the problem.
Again in summary:
Migrated SQL 2000 database to 2005
Have done the copy and attach process to make sure the whole conversion to SQL Server 2005 has taken place.
Have set the compatibility of the database to 90
Updates cause the above error. 
 
 Thanks in advance.
 Don 
 

View 1 Replies View Related

Date Is Not A Recognized Built-in Function Name

Mar 21, 2013

how to format the last part of this query which comes from Access.:

SELECT Max(TITLOC.TitleLocID) AS MaxOfTitleLocID, TITLES.TitleID, TITLES.CustLName, TITLES.CustFName, TITLES.RecDT, TITLES.TitleID
FROM (TITLES_WARNING_SENT_qry RIGHT JOIN TITLES ON TITLES_WARNING_SENT_qry.TitleID = TITLES.TitleID) INNER JOIN TITLOC ON TITLES.TitleID = TITLOC.TitleID
WHERE TITLES_WARNING_SENT_qry.TitleID Is Null
GROUP BY TITLES.CustLName, TITLES.CustFName, TITLES.RecDT, TITLES.TitleID, TITLES.TitleID
HAVING (TITLES.RecDT<Date()-31)

I am getting:
'Date' is not a recognized built-in function name.

It is probably something simple but how would I go about converting this part "HAVING (TITLES.RecDT<Date()-31)" to something SQL Server is happy with?

View 4 Replies View Related

SQL 2012 :: AVG Is Not A Recognized Built-in Function Name

Nov 10, 2014

I am trying to pull a report with average down time and I getting the error message "Msg 195, Level 15, State 10, Line 4 'AVG' is not a recognized built-in function name." when I try to run the below query. How can I rephrase the AVG(DateDiff) line to calculate this for me?

SELECT
TT.PartNumber
,AVG (TT.TimeToRepair) as [Avg Time to Repair (Hours)]
,AVG(DateDiff (hour,TT.TimeDateReported,TT.DateClosed) as [Turnaround Time(Hours)])
FROM dbo.vt_TroubleTicket TT
WHERE TT.Closed = '-1'
and TT.DateClosed between '1/1/2013' and '1/1/2014'
and (TT.PartNumber = '12345')
GROUP BY TT.PartNumber

View 3 Replies View Related

OBJECT_SCHEMA_NAME Is Not A Recognized Built-in Function Name

Jan 28, 2008

why I am getting this error on the SQl Server 2005 but not getting it on the SQL Server Express? and how to ifx?





Code Snippet

Msg 195, Level 15, State 10, Procedure sp_check_sp, Line 14
'OBJECT_SCHEMA_NAME' is not a recognized built-in function name.


this is my code:





Code Snippet

USE shefa
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
ALTER PROCEDURE [dbo].[sp_check_sp]
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;

SELECT DB_NAME(st.dbid) DBName
, OBJECT_SCHEMA_NAME(st.objectid, dbid) SchemaName
, OBJECT_NAME(st.objectid, dbid) StoredProcedure
, MAX(cp.usecounts) Execution_count
FROM sys.dm_exec_cached_plans cp
CROSS APPLY sys.dm_exec_sql_text(cp.plan_handle) st
WHERE DB_NAME(st.dbid) IS NOT NULL AND cp.objtype = 'proc'
GROUP BY cp.plan_handle, DB_NAME(st.dbid),
OBJECT_SCHEMA_NAME(objectid, st.dbid),
OBJECT_NAME(objectid, st.dbid)
ORDER BY MAX(cp.usecounts)
END

View 4 Replies View Related

SQL Error 'INITCOLVS' Is Not A Recognized Built-in Function Name.

Jan 30, 2007

Hello All,
Can anyone tell me what is  error is and how to resolve it?
Thanks.

View 4 Replies View Related

Any Built-in Function To Show Table Relationship?

Feb 5, 2007

Hi guys

I have a table which I need to analyze, what jobs this is working with, what stored procedure is calling this table etc. Is there any built-in function to show me or anybody know how to do it? This is my new job, and there are hundreds of stored procedures and jobs, do i really have to go thru one by one?

Please help.

Michelle

View 3 Replies View Related

‘default To Local Cursor’ Causes Errors In String-built Declares

Sep 20, 2000

Hi,

I would like to use the dboption ‘default to local cursor’ to true.

But when I set it to true for my database, cursors that are built in a ‘string’ and then executed return an error :

Select @SQL = 'Declare SICCursor cursor For Select SIC1 From ' + @StateTable + ' Where BusinessName = ' + '''' + @BusinessName + '''' + ' Order By PubDate desc'

Exec(@SQL)

Open SICCursor

Openning the cursor returns the error message

“A cursor with the name 'SICCursor' does not exist.”

What am I doing wrong (cursors declared ‘normally’ do not have a problem)?

Thanks,
Judith

View 1 Replies View Related

Search Char In SQL Query

Jul 10, 2006

I have a text field in a table that contains number along with chars.Is there a way i can write a query to show all the fields that containsjust Numbers or Char in a field??TBALE ExampleCOL1 : COL2(nvarchar)---------------------------100 345G01200 123456789300 GQ9220

View 7 Replies View Related

Yet Another SQLBindParameter Thread -- Char* As A Parameter? (already Did A Search)

May 3, 2007

Hi guys, first post here. It's been a few years since I've worked with ODBC, so I'm a bit rusty. I'm having trouble figuring out how to use a char* string as a parameter for a SELECT statement. I'm trying to compare the contents of a varchar column (with size=20) against the string.

Here's the code that I'm using:


char* arg;
SQLINTEGER stringSize = 32;

retcode = SQLBindParameter(hstmt,
1,
SQL_PARAM_INPUT,
SQL_C_CHAR,
SQL_VARCHAR,
20,
0,
arg,
stringSize,
&stringSize);

retcode = SQLPrepare(hstmt,
(SQLCHAR*) "SELECT * "
"FROM myTable "
"WHERE (stringColumn = '?')",
SQL_NTS);

retcode = SQLExecute(hstmt);

retcode = SQLFetch(hstmt);

When SQLFetch() runs, it returns 100 (SQL_NO_DATA). If I type the query manually into my Enterprise Manager console, I get several results, so I know the query is correct. Any idea what I might be doing wrong with the ODBC calls?

Thanks!

View 1 Replies View Related

Search And Replace Only Replaces One Char Per Field

Sep 22, 2006

I am attempting to find quotes (") in a column and replace with the string '--THIS-WAS-QUOTES--'. Right now my script only converts the first quote it finds in the description column, converts to the string and moves to the next row leaving the other quotes as they were. Below is my query script

DECLARE @find varchar(8000),
@replace varchar(8000),
@patfind varchar(8000)

SELECT @find = '"',
@replace = '--THIS-WAS-QUOTES--'

SELECT @patfind = '%' + @find + '%'

UPDATE Incident
SET description = STUFF(convert( varchar(8000), description ),
PATINDEX( @patfind, description ),
DATALENGTH( @find ),
@replace )
WHERE description LIKE @patfind

View 1 Replies View Related

Search And Replace Only Replaces One Char Per Field

Sep 26, 2006

I am attempting to find quotes (") in a column and replace with the string '--THIS-WAS-QUOTES--'. Right now my script only converts the first quote it finds in the description column, converts to the string and moves to the next row leaving the other quotes as they were. Below is my query script

DECLARE @find varchar(8000),
@replace varchar(8000),
@patfind varchar(8000)

SELECT @find = '"',
@replace = '--THIS-WAS-QUOTES--'

SELECT @patfind = '%' + @find + '%'

UPDATE Incident
SET description = STUFF(convert( varchar(8000), description ),
PATINDEX( @patfind, description ),
DATALENGTH( @find ),
@replace )
WHERE description LIKE @patfind

View 4 Replies View Related

This Stored Procedure Can Be Used To Search And Replace Substring In The Char, Nchar,

Jan 9, 2006

#1 This stored procedure can be used to search and replace substring in the char, nchar, varchar and nvarchar columns in all tables in the current database. You should pass the text value to search and the text value to replace. So, to replace all char, nchar, varchar and nvarchar columns which contain the substring 'John' with the substring 'Bill', you can use the following (in comparison with the SetTbColValues stored procedure, this stored procedure replace only substring, not the entire column's value):

EXEC replace_substring @search_value = 'John', @replace_value = 'Bill'

View 2 Replies View Related

Replace Char At End Of String

Mar 2, 2000

Hi,

I have a table where this one column(varchar) has rows of data with a period at the end of the string. Is there any function I could use to remove all the periods?

For eg:
bhjio.
shtpl.

should become:
bhjio
shtpl

Thanks

View 1 Replies View Related

Char Count In String

Jul 31, 2013

I have a string like aaannbbghtgggbbaa, I want a query to get count of characters in string like :

a 5
b 4
others 20

View 3 Replies View Related

SQL Server 2008 :: Search Each And Every String In Comma Delimited String Input (AND Condition)

Mar 10, 2015

I have a scenario where in I need to use a comma delimited string as input. And search the tables with each and every string in the comma delimited string.

Example:
DECLARE @StrInput NVARCHAR(2000) = '.NET,Java, Python'

SELECT * FROM TABLE WHERE titleName = '.NET' AND titleName='java' AND titleName = 'Python'

As shown in the example above I need to take the comma delimited string as input and search each individual string like in the select statement.

View 3 Replies View Related

How To Compare Nvarchar(15), Char(5), And String

Jan 31, 2008

I have used a query statement with the following WHERE string to 'Fill'  a dataset.  
"AND (A.ApptsDate > '" & strApptPreDate & "' OR (A.ApptsDate = '" & strApptPreDate & "' AND A.ApptsTime >= '" & strApptPreTime & "' ))" & _ and strApptPreTime is defined as:Dim strApptPreTime As String = SomaShared.strPadTime(CStr(dApptCalcNewDate.Hour) + ":" + CStr(dApptCalcNewDate.Minute))
 
Somehow, the dataset showed only the ApptsTime after 10 am.  After more than 2 weeks of debugging, I still can see a dataset watch for > 10 amAppsTime only.   Now I am guessting, the problem is 9 is different from 10 - 16, it all because 9 is single digit.  Then I check the data type settings for these variables.  Here are what I found:
In SQL Server Agent job, the ApptsTime data was 'inserted' by @NewApptTimes, which is declared as char(5).In SQL Server database, the ApptsTime was defined as nvarchar(15).
My question are:     1. The reason why there were no 9 am data for the dataset, is becasue 9 am of nvarchar(15) is not > 8:30 of strApptPreTime?     2. If the answer to the quation 1 is yes, how do I define AppsTime and/or strApptPreTime?
 TIA,Jeffrey 

View 6 Replies View Related

Change Char String To A Date?

Oct 12, 2013

To change string '24.04.2013' (Apr. 24, 2013 format of dd-mm-yyyy) into a date in format of mm-dd-yyyy, what's the easiest way?

View 5 Replies View Related

Turn Hex Into Char String And Concatenate

Feb 16, 2006

I've been trying to return hex data in a way that can be concatenated.
I need the actual hex info (e.g. 0x6E3C070) as displayed
since it contains info about the path to a file.
So I can turn it into D:6E3C7 to get the path to the file.
In searching around I have come across a way to do this but can't figure out how to get it to run through a column and either display or insert into a table multiple results.

-Here's the user function that converts an integer into a hex string-

CREATE FUNCTION udf_hex_string (@i int)
RETURNS varchar(30) AS
BEGIN
DECLARE @vb varbinary(8)
SET @vb = CONVERT(varbinary(8),@i)
DECLARE @hx varchar(30)
EXEC master..xp_varbintohexstr @vb, @hx OUT
RETURN @hx
END
GO


-Using this table-

create table
XPages
(PageStoreId int null,
HexString varchar (30) null,
VolumePath varchar (60) null, )


--'PageStoreId' contains the data that needs to be converted into the editable hex string
--'HexString' is where I'd like it to go so I can parse it later.

--I can run the below select and get the hex string. But am stuck on how to run a select or update that would run through the 'XPages.PagestoreId'
column and insert the hex string into the 'XPages.Hexstring' column. 'XPages.PagestoreId' could have 100's of entries that need to be converted and placed in the relevant the 'XPages.Hexstring' column.


SELECT dbo.udf_hex_string(1234)



Thanks

View 3 Replies View Related

How To Drop Intro Char In A String?

Nov 21, 2007

Hi guys,


From my DTS is like this:

DTSDestination("Tex") = replace(DTSSource("Tex"),Chr(13) & Chr(10), "<br>")

And now I try unsuccesfully this one on a Derived Column task

REPLACE([Tex], Chr(13), " " )

TIA

View 1 Replies View Related

Transact SQL :: Search And Return String After Searched String

Sep 1, 2015

Is there way to search for the particular string and return the string after that searched string

SalesID
Rejection reason
21812

[code]....

The timeout period elapsed hence disqualified

View 3 Replies View Related

How To Retrieve The Char(1) Column From SQL Server With Dbbind() Function In Windows C Programming?

May 10, 2007

I have used the following Windows C codes to retrieve records from the bus_newjob table in SQL server:



==========================================================

// construct command buffer to be sent to the SQL server
dbcmd( dbproc, ( char * )"select job_number, job_type," );
dbcmd( dbproc, ( char * )" disp_type, disp_status," );
dbcmd( dbproc, ( char * )" start_time, end_time," );
dbcmd( dbproc, ( char * )" pickup_point, destination," );
dbcmd( dbproc, ( char * )" veh_plate, remark," );
dbcmd( dbproc, ( char * )" customer, cust_contact_person," );
dbcmd( dbproc, ( char * )" cust_contact_number, cust_details" );
dbcmd( dbproc, ( char * )" from bus_newjob" );
dbcmd( dbproc, ( char * )" where disp_status = 0" );
dbcmd( dbproc, ( char * )" order by job_number asc" );

result_code = dbsqlexec( dbproc ); // send command buffer to SQL server

// now check the results from the SQL server
while( ( result_code = dbresults( dbproc ) ) != NO_MORE_RESULTS )
{
if( result_code == SUCCEED )
{
memset( ( char * )&disp_job, 0, sizeof( DISPATCH_NEWJOB ) );
dbbind( dbproc, 1, INTBIND, ( DBINT )0, ( LPBYTE )&disp_job.new_job.job_number );
dbbind( dbproc, 2, NTBSTRINGBIND, ( DBINT )0, ( LPBYTE )&disp_job.new_job.job_type );
dbbind( dbproc, 3, INTBIND, ( DBINT )0, ( LPBYTE )&disp_job.new_job.disp_type );
dbbind( dbproc, 4, INTBIND, ( DBINT )0, ( LPBYTE )&disp_job.new_job.disp_status );
dbbind( dbproc, 5, NTBSTRINGBIND, ( DBINT )0, ( LPBYTE )&disp_job.new_job.start_time );
dbbind( dbproc, 6, NTBSTRINGBIND, ( DBINT )0, ( LPBYTE )&disp_job.new_job.end_time );
dbbind( dbproc, 7, NTBSTRINGBIND, ( DBINT )0, ( LPBYTE )&disp_job.new_job.pickup_point );
dbbind( dbproc, 8, NTBSTRINGBIND, ( DBINT )0, ( LPBYTE )&disp_job.new_job.destination );
dbbind( dbproc, 9, NTBSTRINGBIND, ( DBINT )0, ( LPBYTE )&disp_job.new_job.veh_plate );
dbbind( dbproc, 10, NTBSTRINGBIND, ( DBINT )0, ( LPBYTE )&disp_job.new_job.remark );
dbbind( dbproc, 11, NTBSTRINGBIND, ( DBINT )0, ( LPBYTE )&disp_job.new_job.customer );
dbbind( dbproc, 12, NTBSTRINGBIND, ( DBINT )0, ( LPBYTE )&disp_job.new_job.cust_contact_person );
dbbind( dbproc, 13, NTBSTRINGBIND, ( DBINT )0, ( LPBYTE )&disp_job.new_job.cust_contact_number );
dbbind( dbproc, 14, NTBSTRINGBIND, ( DBINT )0, ( LPBYTE )&disp_job.new_job.cust_details );

// now process the rows
while( dbnextrow( dbproc ) != NO_MORE_ROWS )
{
new_job = malloc( sizeof( DISPATCH_NEWJOB ) );
if( !new_job )
return( 0 );
memcpy( ( char * )new_job, ( char * )&disp_job, sizeof( DISPATCH_NEWJOB ) );
append_to_list( &Read_Job_List, new_job );
}
}
else
{
sprintf( str, "Results Failed, result_code = %d", result_code );
log_str( str );
break;
}
==========================================================



where the job_type columIn is of the char(1) type, NTBSTRINGBIND is the vartype argument in the dbbind() function.



However, what I have gotten is nothing more than a null string from the job_type column. I have alternatively changed the vartype argument to STRINGBIND, CHARBIND and even INTBIND, but the results are the same.



Who can tell me the tricks to retrieve a char(1) column from SQL server?



View 1 Replies View Related

What Is The Difference Between Updating Null Value Vs Empty String To Varchar/char Field?

Aug 29, 2007

Hi,
What is the difference updating a null value to char/varchar type column

versus empty string to char/varchar type column?Which is the best to do and why?
Could anyone explain about this?

Example:

Table 1 : tCountry - Name varchar(80) nullable
Table 2 :tState - Name char(2) nullable
Table 3 :tCountryDetails - countryid,state (char(2) nullable) - May the country contain state or no state
So,when the state is not present for the country ,i have two options may be - null,''
tCountryDetails.State = '' or tCountryDetails.State = null?

View 9 Replies View Related

Search Function

Apr 4, 2007

I am trying to write a used car search function I want the user to be able to select a MAKE from the 1st drop down list and a MODEL from the second drop down list and click a button and for the data to be shown in a gridview, the code below is what I have so far and works i.e when user selects a make it shows all cars for that make, but now how do I take it further and add the model on there so that when the user selects i.e BMW as make and Z3 for model it only shows all BMW Z3'S
 
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>">
</asp:SqlDataSource>
<br />
<asp:DropDownList ID="ddmake" runat="server" DataSourceID="SqlDataSource2" DataTextField="make"
DataValueField="make" AutoPostBack="True">
</asp:DropDownList><asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT DISTINCT [make] FROM [used]"></asp:SqlDataSource>
&nbsp;&nbsp;</div>
<asp:button id="button1" runat="server" text="search"/>
<asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1">
</asp:GridView>
&nbsp;
</form>
</body>
</html>
 
Here is the code behind the page
Protected Sub button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles button1.Click
SqlDataSource1.SelectCommand = "select * from [used] where make like '%" & ddmake.Text & "%'"
SqlDataSource1.DataBind()
End Sub

View 26 Replies View Related

Search Function

Nov 28, 2007

We are in the process of developing an onlinestore like www.componentsource.com.We need to search for a product within our website.We already created pages using html.I have to take the 1st para of the product description and display. I don't want to save the description in the table how to do it? 

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved