| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1111 人关注过本帖
标题:测试时,为什么出错?
取消只看楼主 加入收藏
mao_x_r
Rank: 1
等 级:新手上路
帖 子:81
专家分:0
注 册:2006-6-6
收藏
 问题点数:0 回复次数:15 
测试时,为什么出错?
用visual 开发软件,测试时总是提示sqlDataAdapter1.Fill(dsAuthor)这句话出错,到底是什么原因呢?请各位高手指教,谢谢!
搜索更多相关主题的帖子: 测试 软件 visual 开发 
2007-05-16 22:12
mao_x_r
Rank: 1
等 级:新手上路
帖 子:81
专家分:0
注 册:2006-6-6
收藏
得分:0 
我想插入图片让大家看看,怎么上传图片呢?
2007-05-16 22:15
mao_x_r
Rank: 1
等 级:新手上路
帖 子:81
专家分:0
注 册:2006-6-6
收藏
得分:0 
如何发代码呀?试了几次传不过来,急!急!急!
2007-05-16 23:06
mao_x_r
Rank: 1
等 级:新手上路
帖 子:81
专家分:0
注 册:2006-6-6
收藏
得分:0 
这错误到底怎么解决,请高手们一定要耐心指点一下.
2007-05-27 22:11
mao_x_r
Rank: 1
等 级:新手上路
帖 子:81
专家分:0
注 册:2006-6-6
收藏
得分:0 
[CODE]
<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="mmApplication1.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<FONT face="宋体">
<asp:DataGrid id=DataGrid1 style="Z-INDEX: 101; LEFT: 64px; POSITION: absolute; TOP: 40px" runat="server" Width="432px" Height="176px" DataSource="<%# dsA0uthors1 %>" DataMember="goods" DataKeyField="goods_id" AutoGenerateColumns="False">
<Columns>
<asp:BoundColumn DataField="goods_id" SortExpression="goods_id" HeaderText="goods_id"></asp:BoundColumn>
<asp:BoundColumn DataField="goods_name" SortExpression="goods_name" HeaderText="goods_name"></asp:BoundColumn>
<asp:BoundColumn DataField="price" SortExpression="price" HeaderText="price"></asp:BoundColumn>
<asp:BoundColumn DataField="provider" SortExpression="provider" HeaderText="provider"></asp:BoundColumn>
<asp:BoundColumn DataField="more" SortExpression="more" HeaderText="more"></asp:BoundColumn>
</Columns>
</asp:DataGrid></FONT>
</form>
</body>
</HTML>[/CODE]
2007-05-27 22:17
mao_x_r
Rank: 1
等 级:新手上路
帖 子:81
专家分:0
注 册:2006-6-6
收藏
得分:0 
上面是主文件代码,再发一个后台文件代码
2007-05-27 22:18
mao_x_r
Rank: 1
等 级:新手上路
帖 子:81
专家分:0
注 册:2006-6-6
收藏
得分:0 

[CODE]using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace mmApplication1
{
/// <summary>
/// WebForm1 的摘要说明。
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected System.Data.SqlClient.SqlCommand sqlSelectCommand1;
protected System.Data.SqlClient.SqlCommand sqlInsertCommand1;
protected System.Data.SqlClient.SqlCommand sqlUpdateCommand1;
protected System.Data.SqlClient.SqlCommand sqlDeleteCommand1;
protected System.Data.SqlClient.SqlConnection sqlConnection1;
protected System.Data.SqlClient.SqlDataAdapter sqlDataAdapter1;
protected mmApplication1.dsA0uthors dsA0uthors1;
protected System.Web.UI.WebControls.DataGrid DataGrid1;

private void Page_Load(object sender, System.EventArgs e)
{
if(! IsPostBack)
{
Bind();
}
}

public void Bind()
{
sqlDataAdapter1.Fill(dsAOuthors1);
DataGrid1.DataSource=dsAOuthors1;
DataGrid1.DataBind();
}

#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.sqlSelectCommand1 = new System.Data.SqlClient.SqlCommand();
this.sqlInsertCommand1 = new System.Data.SqlClient.SqlCommand();
this.sqlUpdateCommand1 = new System.Data.SqlClient.SqlCommand();
this.sqlDeleteCommand1 = new System.Data.SqlClient.SqlCommand();
this.sqlConnection1 = new System.Data.SqlClient.SqlConnection();
this.sqlDataAdapter1 = new System.Data.SqlClient.SqlDataAdapter();
this.dsA0uthors1 = new mmApplication1.dsA0uthors();
((System.ComponentModel.ISupportInitialize)(this.dsA0uthors1)).BeginInit();
//
// sqlSelectCommand1
//
this.sqlSelectCommand1.CommandText = "SELECT id, goods_id, goods_name, price, provider, more FROM goods";
this.sqlSelectCommand1.Connection = this.sqlConnection1;
//
// sqlInsertCommand1
//
this.sqlInsertCommand1.CommandText = "INSERT INTO goods(goods_id, goods_name, price, provider, more) VALUES (@goods_id," +
" @goods_name, @price, @provider, @more); SELECT id, goods_id, goods_name, price," +
" provider, more FROM goods WHERE (id = @@IDENTITY)";
this.sqlInsertCommand1.Connection = this.sqlConnection1;
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@goods_id", System.Data.SqlDbType.Int, 4, "goods_id"));
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@goods_name", System.Data.SqlDbType.VarChar, 50, "goods_name"));
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@price", System.Data.SqlDbType.Money, 8, "price"));
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@provider", System.Data.SqlDbType.VarChar, 50, "provider"));
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@more", System.Data.SqlDbType.VarChar, 50, "more"));
//
// sqlUpdateCommand1
//
this.sqlUpdateCommand1.CommandText = @"UPDATE goods SET goods_id = @goods_id, goods_name = @goods_name, price = @price, provider = @provider, more = @more WHERE (id = @Original_id) AND (goods_id = @Original_goods_id) AND (goods_name = @Original_goods_name) AND (more = @Original_more OR @Original_more IS NULL AND more IS NULL) AND (price = @Original_price OR @Original_price IS NULL AND price IS NULL) AND (provider = @Original_provider OR @Original_provider IS NULL AND provider IS NULL); SELECT id, goods_id, goods_name, price, provider, more FROM goods WHERE (id = @id)";
this.sqlUpdateCommand1.Connection = this.sqlConnection1;
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@goods_id", System.Data.SqlDbType.Int, 4, "goods_id"));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@goods_name", System.Data.SqlDbType.VarChar, 50, "goods_name"));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@price", System.Data.SqlDbType.Money, 8, "price"));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@provider", System.Data.SqlDbType.VarChar, 50, "provider"));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@more", System.Data.SqlDbType.VarChar, 50, "more"));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_id", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "id", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_goods_id", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "goods_id", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_goods_name", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "goods_name", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_more", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "more", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_price", System.Data.SqlDbType.Money, 8, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "price", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_provider", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "provider", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@id", System.Data.SqlDbType.Int, 4, "id"));
//
// sqlDeleteCommand1
//
this.sqlDeleteCommand1.CommandText = @"DELETE FROM goods WHERE (id = @Original_id) AND (goods_id = @Original_goods_id) AND (goods_name = @Original_goods_name) AND (more = @Original_more OR @Original_more IS NULL AND more IS NULL) AND (price = @Original_price OR @Original_price IS NULL AND price IS NULL) AND (provider = @Original_provider OR @Original_provider IS NULL AND provider IS NULL)";
this.sqlDeleteCommand1.Connection = this.sqlConnection1;
this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_id", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "id", System.Data.DataRowVersion.Original, null));
this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_goods_id", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "goods_id", System.Data.DataRowVersion.Original, null));
this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_goods_name", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "goods_name", System.Data.DataRowVersion.Original, null));
this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_more", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "more", System.Data.DataRowVersion.Original, null));
this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_price", System.Data.SqlDbType.Money, 8, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "price", System.Data.DataRowVersion.Original, null));
this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_provider", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "provider", System.Data.DataRowVersion.Original, null));
//
// sqlConnection1
//
this.sqlConnection1.ConnectionString = "workstation id=515461FB4184469;packet size=4096;integrated security=SSPI;data sou" +
"rce=localhost;persist security info=False;initial catalog=wlb";
//
// sqlDataAdapter1
//
this.sqlDataAdapter1.DeleteCommand = this.sqlDeleteCommand1;
this.sqlDataAdapter1.InsertCommand = this.sqlInsertCommand1;
this.sqlDataAdapter1.SelectCommand = this.sqlSelectCommand1;
this.sqlDataAdapter1.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
new System.Data.Common.DataTableMapping("Table", "goods", new System.Data.Common.DataColumnMapping[] {
new System.Data.Common.DataColumnMapping("id", "id"),
new System.Data.Common.DataColumnMapping("goods_id", "goods_id"),
new System.Data.Common.DataColumnMapping("goods_name", "goods_name"),
new System.Data.Common.DataColumnMapping("price", "price"),
new System.Data.Common.DataColumnMapping("provider", "provider"),
new System.Data.Common.DataColumnMapping("more", "more")})});
this.sqlDataAdapter1.UpdateCommand = this.sqlUpdateCommand1;
//
// dsA0uthors1
//
this.dsA0uthors1.DataSetName = "dsA0uthors";
this.dsA0uthors1.Locale = new System.Globalization.CultureInfo("zh-CN");
this.Load += new System.EventHandler(this.Page_Load);
((System.ComponentModel.ISupportInitialize)(this.dsA0uthors1)).EndInit();

}
#endregion
}
}

[/CODE]

2007-05-27 22:19
mao_x_r
Rank: 1
等 级:新手上路
帖 子:81
专家分:0
注 册:2006-6-6
收藏
得分:0 
[IMG]http://192.168.1.2/E:/111.jpg[/IMG]
2007-05-27 22:24
mao_x_r
Rank: 1
等 级:新手上路
帖 子:81
专家分:0
注 册:2006-6-6
收藏
得分:0 
[IMG]http://192.168.1.2/111.jpg[/IMG]
2007-05-27 22:24
mao_x_r
Rank: 1
等 级:新手上路
帖 子:81
专家分:0
注 册:2006-6-6
收藏
得分:0 
图片附件: 游客没有浏览图片的权限,请 登录注册

2007-05-27 22:25
快速回复:测试时,为什么出错?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.026024 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved