amillyard
asked on
enter a case/account number (via a form text field), press the submit button (to search/find account).
Development Platform: c#, asp.net 2.x, Visual Studio Pro utilising Web Developer, IIS 6, SQL Server 2005
Want to be able to enter a case/account number (via a form text field), press the submit button (to search/find account).
return back some of the record fields (columns) pertaining to that account record...also, if record not find (i.e. typed an incorrect account number, an error message indicating so).
Below I have a script that worked with finding the first successful response in database -- as we are searching for unique account numbers within database, assuming this is still the better way forward for getting some of the account details.
Previously, I used this script to return a string value -- but this time, am returning the index/integer field -- cannot seem to get this to work properly (conversion issue).
Also, how do I pull back more fields from the same record (like, name, address etc).
Thank you in advance for your time and efforts with this enquiry.
SqlDataSource FORTUNESQLDataSource = new SqlDataSource();
FORTUNESQLDataSource.Conne ctionStrin g = ConfigurationManager.Conne ctionStrin gs["FORTUN EConnectio nString"]. ToString() ;
string MasterAccountSearch_ID = "";
using (SqlConnection FORTUNEConnection1 = new SqlConnection(FORTUNESQLDa taSource.C onnectionS tring))
{
FORTUNEConnection1.Open();
SqlCommand scCommand = new SqlCommand((String.Format( "SELECT [MasterAccount_ID] FROM [MasterAccounts] WHERE [MasterAccount_ID] = '{0}'", TextBox_SearchMasterAccoun ts.Text)), FORTUNEConnection1);
MasterAccountSearch_ID = (string)scCommand.ExecuteS calar();
FORTUNEConnection1.Close() ;
}
Want to be able to enter a case/account number (via a form text field), press the submit button (to search/find account).
return back some of the record fields (columns) pertaining to that account record...also, if record not find (i.e. typed an incorrect account number, an error message indicating so).
Below I have a script that worked with finding the first successful response in database -- as we are searching for unique account numbers within database, assuming this is still the better way forward for getting some of the account details.
Previously, I used this script to return a string value -- but this time, am returning the index/integer field -- cannot seem to get this to work properly (conversion issue).
Also, how do I pull back more fields from the same record (like, name, address etc).
Thank you in advance for your time and efforts with this enquiry.
SqlDataSource FORTUNESQLDataSource = new SqlDataSource();
FORTUNESQLDataSource.Conne
string MasterAccountSearch_ID = "";
using (SqlConnection FORTUNEConnection1 = new SqlConnection(FORTUNESQLDa
{
FORTUNEConnection1.Open();
SqlCommand scCommand = new SqlCommand((String.Format(
MasterAccountSearch_ID = (string)scCommand.ExecuteS
FORTUNEConnection1.Close()
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
ok, understand what you are saying with both comments.
the workflow is that there is a search box (enter text), then press submit to check if account is available.
once the account has been found (confirmed) -- the asp page stores that account number in a session variable as the current account working on -- then redirects to another asp page, which then upon loading page, gets the relevant table information and subsequently use the dataset as recommended above -- this redirected page knows what account to pull by using the session variable stored for reference just earlier.
what am I needing further advise on then?
1. the above scripting (or alternative) -- to simply check if a record exists and return a variable response indicating found or not found.
2. MasterAccountSearch_ID = (string)scCommand.ExecuteS calar();
this part compiles ok -- but not works online as the MasterAccountSearch_ID is a string, but the database record variable is an Int (primary key field) -- would do not I need to change on that line?
many thanks,
the workflow is that there is a search box (enter text), then press submit to check if account is available.
once the account has been found (confirmed) -- the asp page stores that account number in a session variable as the current account working on -- then redirects to another asp page, which then upon loading page, gets the relevant table information and subsequently use the dataset as recommended above -- this redirected page knows what account to pull by using the session variable stored for reference just earlier.
what am I needing further advise on then?
1. the above scripting (or alternative) -- to simply check if a record exists and return a variable response indicating found or not found.
2. MasterAccountSearch_ID = (string)scCommand.ExecuteS
this part compiles ok -- but not works online as the MasterAccountSearch_ID is a string, but the database record variable is an Int (primary key field) -- would do not I need to change on that line?
many thanks,
Just add the columns you need to the query
SELECT [MasterAccount_ID],name, address, watever FROM [MasterAccounts] WHERE [MasterAccount_ID] = '{0}'", TextBox_SearchMasterAccoun