我想通过用户输入搜索一个特定的号码......这个 si 目前无法正常工作,但是即使我硬编码一个号码,它仍然不会接收任何内容。我不确定我做错了什么。请帮助我,这是相当紧急的。
谢谢你,文件在下面。
.cs 文件
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.OleDb;
using System.Data.SqlClient;
namespace SearchC
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void SearchClick(object sender, EventArgs e)
{
string searchPAS = txtSearch.Text;
using (var sqlconnection = new SqlConnection(Search)
{
string strQuery = "Select PAS_NO from P_DETAILS where PAS_NO = searchPAS";
SqlCommand command = new SqlCommand(strQuery, sqlconnection) { CommandType = CommandType.Text };
var ptnt = command.ExecuteScalar();
txtPAS.Text = ptnt.ToString();
}
}
}
}
网络配置文件
<configuration>
<connectionStrings>
<add name="Search" connectionString="Data Source=dwh;User ID=***;Password=***;Unicode=True"
providerName="System.Data.OracleClient" />
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<authentication mode="Forms">
<forms loginUrl="~/Account/Login.aspx" timeout="2880" />
</authentication>
<membership>
<providers>
<clear/>
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices"
enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false"
maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10"
applicationName="/" />
</providers>
</membership>
<profile>
<providers>
<clear/>
<add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/"/>
</providers>
</profile>
<roleManager enabled="false">
<providers>
<clear/>
<add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/" />
<add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" />
</providers>
</roleManager>
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
.aspx 文件
<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
CodeBehind="Default.aspx.cs" Inherits="SearchC._Default" %>
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<table>
<tr>
<td>
PAS NUmber
</td>
<td>
<asp:TextBox ID="txtSearch" runat="server"></asp:TextBox>
</td>
</tr>
<tr >
<td >
<asp:Button runat="server" ID="btnSearch" OnClick="SearchClick" Text="Search"/>
</td>
</tr>
<tr >
<td >
<asp:TextBox ID="txtPAS" runat="server"></asp:TextBox>
</td>
</tr>
</table>
</asp:Content>
这就是我现在所拥有的......我不确定它为什么不工作,当我按下按钮时它只是闪烁,没有其他反应