Click here to Skip to main content
15,890,670 members
Home / Discussions / C#
   

C#

 
QuestionHi guys Pin
Member 119112491-Sep-15 14:58
Member 119112491-Sep-15 14:58 
AnswerRe: Hi guys Pin
Dave Kreskowiak1-Sep-15 15:27
mveDave Kreskowiak1-Sep-15 15:27 
Generalrotation collision response? Pin
Isawyouoo1-Sep-15 2:17
Isawyouoo1-Sep-15 2:17 
GeneralRe: rotation collision response? Pin
Pete O'Hanlon1-Sep-15 4:21
mvePete O'Hanlon1-Sep-15 4:21 
Generalc# partner wanted Pin
Member 110021371-Sep-15 1:22
Member 110021371-Sep-15 1:22 
GeneralRe: c# partner wanted Pin
Richard MacCutchan1-Sep-15 1:42
mveRichard MacCutchan1-Sep-15 1:42 
GeneralRe: c# partner wanted Pin
OriginalGriff1-Sep-15 4:32
mveOriginalGriff1-Sep-15 4:32 
QuestionCompare data entered through multiple input fields with stored values in dataset. Pin
Rajesh_198031-Aug-15 8:27
Rajesh_198031-Aug-15 8:27 
I am able to compare the entered value of an input field with stored values in a dataset. However, I am having trouble doing the same with multiple input fields. Here is my code with single input field. Please advise how to go about the same with multiple input fields. Thanks in advance for any help.

C#
protected void Submit_click(object sender, EventArgs e)
       {
           // Create connection string variable. Modify the "Data Source"
           // parameter as appropriate for your environment.
           string path = @"C:\TEMP\ExcelSearchWebApp\OneWayContainers.xlsx";
           string connStr = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path + ";Extended Properties=Excel 12.0;";

           // Create connection object by using the preceding connection string.
           OleDbConnection objConn = new OleDbConnection(connStr);

           // Open connection with the database.
           objConn.Open();

           // The code to follow uses a SQL SELECT command to display the data from the worksheet.

           // Create new OleDbCommand to return data from worksheet.
           OleDbCommand objCmdSelect = new OleDbCommand("SELECT * FROM MyRange", objConn);

           // Create new OleDbDataAdapter that is used to build a DataSet
           // based on the preceding SQL SELECT statement.
           OleDbDataAdapter objAdapter1 = new OleDbDataAdapter();

           // Pass the Select command to the adapter.
           objAdapter1.SelectCommand = objCmdSelect;

           // Create new DataSet to hold information from the worksheet.
           DataSet objDataset1 = new DataSet();

           // Fill the DataSet with the information from the worksheet.
           objAdapter1.Fill(objDataset1, "XLData");

           string strExcelContainerInfo;
           string strContainerInfoText= Convert.ToString(txtCntrInfo.Text).ToUpper();


           if (objDataset1.Tables[0].Rows.Count > 0)
           {
               for (int i = 0; i < objDataset1.Tables[0].Rows.Count; i++)
               {
                   strExcelContainerInfo = Convert.ToString(objDataset1.Tables[0].Rows[i]["OneWayContainers"].ToString());       //fetch Name clm from db

                   if (strContainerInfoText == strExcelContainerInfo )
                   {
                       ScriptManager.RegisterStartupScript(this, this.GetType(),"alert","alert('OneWayContainer');window.location ='RedirectPage.aspx';",true);

                   }
                   else
                   {
                       //Submit form logic;
                   }
               }
           }
           // Clean up objects.
           objConn.Close();
       }


ASP.NET
<form id="form1" runat="server">
    <div>
        <table class="style1">
            <tr>
                <td>
                    <table>
                        <tr>
                            <td>
                                <asp:Label ID="Label1" runat="server" Text="ContainerInfo: "></asp:Label>
                            </td>
                            <td>
                                <asp:TextBox ID="txtCntrInfo" runat="server"></asp:TextBox>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2" align="center">
                                <asp:Button ID="Button1" runat="server" Text="Submit" onclick="Submit_click" />
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
    </div>
    </form>

AnswerRe: Compare data entered through multiple input fields with stored values in dataset. Pin
Eddy Vluggen31-Aug-15 8:52
professionalEddy Vluggen31-Aug-15 8:52 
GeneralRe: Compare data entered through multiple input fields with stored values in dataset. Pin
Rajesh_198031-Aug-15 9:26
Rajesh_198031-Aug-15 9:26 
GeneralRe: Compare data entered through multiple input fields with stored values in dataset. Pin
Eddy Vluggen31-Aug-15 9:48
professionalEddy Vluggen31-Aug-15 9:48 
GeneralRe: Compare data entered through multiple input fields with stored values in dataset. Pin
Rajesh_19801-Sep-15 5:11
Rajesh_19801-Sep-15 5:11 
QuestionTargetInvocationException Pin
Gilbert Consellado29-Aug-15 22:48
professionalGilbert Consellado29-Aug-15 22:48 
AnswerRe: TargetInvocationException Pin
Pete O'Hanlon30-Aug-15 0:01
mvePete O'Hanlon30-Aug-15 0:01 
GeneralRe: TargetInvocationException Pin
Gilbert Consellado30-Aug-15 0:52
professionalGilbert Consellado30-Aug-15 0:52 
GeneralRe: TargetInvocationException Pin
Herman<T>.Instance1-Sep-15 4:31
Herman<T>.Instance1-Sep-15 4:31 
AnswerRe: TargetInvocationException Pin
Eddy Vluggen30-Aug-15 0:44
professionalEddy Vluggen30-Aug-15 0:44 
GeneralRe: TargetInvocationException Pin
Gilbert Consellado30-Aug-15 0:59
professionalGilbert Consellado30-Aug-15 0:59 
QuestionCreating an Auto Purchase Order no with Prefix in asp.net Pin
Member 1158609829-Aug-15 2:05
Member 1158609829-Aug-15 2:05 
AnswerRe: Creating an Auto Purchase Order no with Prefix in asp.net Pin
OriginalGriff29-Aug-15 2:21
mveOriginalGriff29-Aug-15 2:21 
AnswerRe: Creating an Auto Purchase Order no with Prefix in asp.net PinPopular
Dave Kreskowiak29-Aug-15 6:53
mveDave Kreskowiak29-Aug-15 6:53 
GeneralRe: Creating an Auto Purchase Order no with Prefix in asp.net Pin
Pete O'Hanlon29-Aug-15 11:13
mvePete O'Hanlon29-Aug-15 11:13 
AnswerRe: Creating an Auto Purchase Order no with Prefix in asp.net PinPopular
Pete O'Hanlon29-Aug-15 10:05
mvePete O'Hanlon29-Aug-15 10:05 
GeneralRe: Creating an Auto Purchase Order no with Prefix in asp.net Pin
OriginalGriff29-Aug-15 20:30
mveOriginalGriff29-Aug-15 20:30 
QuestionHow can write Algorithm for the following question? Pin
BUNER28-Aug-15 7:55
BUNER28-Aug-15 7:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.