using Visual.Web.Developer.2010.Express;
using SQL.Server.Management.Studio.2008.R2;
私は最終的にやろうとしているが、更新がSQLデータベース..私はこの段階でこだわっている
ですが表示されない..私は印刷する私のWebページを持っています今すぐ、私はテキストボックスにいくつかのコンテンツを入れようとしています。しかし、私がデバッグするたびに、このエラーが表示されます。
この部分にこだわって、私の状況を少し明るく照らしてください。
また、私はこれで正しい方法をとっていますか?これを行うより効果的な方法がありますか?意見やチュートリアルやウォークスルーへのリンクも高く評価されます。前もって感謝します。
マイHTML
SQLの更新テキストボックスは、DB情報
<input runat="server" class="hexen" id="investigate1"/><br />
<input type="text" class="hexen" id="investigate2"/><br />
<input type="text" class="hexen" id="investigate3"/><br />
<input type="text" class="hexen" id="investigate4"/><br />
<input type="text" class="hexen" id="investigate5"/><br />
<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
私のC#
using System;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Services;
namespace WebApplication1
{
public partial class Default1 : System.Web.UI.Page
{
protected void SimpleRead(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection("Data Source=AZUES-336\\JDOESQLSERVER;Initial Catalog=Northwind;Integrated Security=SSPI");
SqlDataReader rdr = null;
try
{
conn.Open();
SqlCommand cmd = new SqlCommand("select * from Customers", conn);
rdr = cmd.ExecuteReader();
if (rdr.Read())
{
investigate1.Text = rdr.GetValue(0).ToString;//Presumably where the error is happening
}
}
finally
{
if (rdr != null)
{ rdr.Close(); }
if (conn != null)
{ conn.Close(); }
}
}
}
}
@ Seany84
Default.aspxの
<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
CodeBehind="Default.aspx.cs" Inherits="WebApplication1.Default1" %>
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<script type="text/javascript">
$(document).ready(function() {
$('.hexen').after('<span class="ui-state-default ui-corner-all ui-icon-disk ui-icon saveButton" title="Save" style="float:left"></span>')// ui icon
.keypress(function() {$(this).next('.saveButton').show();}); //adds ui icon
$('.ui-state-default').hover(
function() {$(this).addClass('ui-state-hover');},
function() {$(this).removeClass('ui-state-hover');}
); //ui icon hover
$('.saveButton').click(function() {
var id = $(this).prev().attr('id'); //used in the "data" attribute of the ajax call
var value = $(this).prev().val(); //used in the "data" attribute of the ajax call
$.ajax({
type: "POST",
url: "Default.aspx",
data: "{Id: " + id + ", Value: " + value + "}",
dataType: "json",
contentType: "application/json; charset=utf-8",
success: function (data) {
console.log(data);
}
});
$(this).hide();
}); //runs ajax call and removes ui-icon after .saveButton is clicked
}); //end .ready
</script>
<input runat="server" class="hexen" id="investigate1"/><br />
<input type="text" class="hexen" id="investigate2"/><br />
<input type="text" class="hexen" id="investigate3"/><br />
<input type="text" class="hexen" id="investigate4"/><br />
<input type="text" class="hexen" id="investigate5"/><br />
<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
</asp:Content>
これはASP.netですか:WebフォームまたはWebページプロジェクトですか? – Seany84
私はWebフォーム.. C#ASP.NET WEB APPLICATION –
ASPXページ全体を投稿することができますか? – Seany84