| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 597 人关注过本帖
标题:[求助]找不出错在哪里...
只看楼主 加入收藏
yjh633
Rank: 1
等 级:新手上路
帖 子:33
专家分:0
注 册:2006-3-11
收藏
 问题点数:0 回复次数:6 
[求助]找不出错在哪里...
[求助]找不出错在哪里...
图片附件: 游客没有浏览图片的权限,请 登录注册

图片附件: 游客没有浏览图片的权限,请 登录注册

[此贴子已经被作者于2006-9-22 15:26:45编辑过]

2006-09-22 15:25
live41
Rank: 10Rank: 10Rank: 10
等 级:贵宾
威 望:67
帖 子:12442
专家分:0
注 册:2004-7-22
收藏
得分:0 
感觉2005的错误提示比2003要差.

那是提示你的strSQL里面错了,你输出一次strSQL看看对不对先吧
2006-09-22 15:36
olive_if
Rank: 1
等 级:新手上路
帖 子:43
专家分:0
注 册:2006-8-2
收藏
得分:0 
发全一点,大家才好帮你找问题啊
2006-09-22 16:06
yjh633
Rank: 1
等 级:新手上路
帖 子:33
专家分:0
注 册:2006-3-11
收藏
得分:0 

using System;
using System.Data;
using System.Data.SqlClient;

namespace WindowsApplication7
{
/// <summary>
/// LinkDataBase 的摘要说明。
/// </summary>
public class LinkDataBase
{
private string strSQL;
//与SQL Server的连接字符串设置
private string connectionString = "workstation id=localhost;Integrated Security=SSPI;database=ye";
//与数据库的连接
private SqlConnection myConnection;

private SqlCommandBuilder sqlCmdBld;
private DataSet ds = new DataSet();
private SqlDataAdapter da;

public LinkDataBase()
{
//
// TODO: 在此处添加构造函数逻辑
//
}

///////////////////////////////// 操作脱机数据库(创建了该类的实例时直接用) /////////////////////////////////////////////////////

//根据输入的SQL语句检索数据库数据
public DataSet SelectDataBase(string tempStrSQL, string tempTableName)
{
this.strSQL = tempStrSQL;
this.myConnection = new SqlConnection(connectionString);
this.da = new SqlDataAdapter(this.strSQL, this.myConnection);
this.ds.Clear();
this.da.Fill(ds,tempTableName);
return ds;//返回填充了数据的DataSet,其中数据表以tempTableName给出的字符串命名
}

//数据库数据更新(传DataSet和DataTable的对象)
public DataSet UpdateDataBase(DataSet changedDataSet, string tableName)
{
this.myConnection = new SqlConnection(connectionString);
this.da = new SqlDataAdapter(this.strSQL, this.myConnection);
this.sqlCmdBld = new SqlCommandBuilder(da);
this.da.Update(changedDataSet, tableName);
return changedDataSet;//返回更新了的数据库表
}

///////////////////////////////// 直接操作数据库(未创建该类的实例时直接用) /////////////////////////////////////////////////////

//检索数据库数据(传字符串,直接操作数据库)
public DataTable SelectDataBase(string tempStrSQL)
{
this.myConnection = new SqlConnection(connectionString);
DataSet tempDataSet = new DataSet();
this.da = new SqlDataAdapter(tempStrSQL, this.myConnection);
this.da.Fill(tempDataSet);
return tempDataSet.Tables[0];

}

//数据库数据更新(传字符串,直接操作数据库)
public int UpdateDataBase(string tempStrSQL)
{
this.myConnection = new SqlConnection(connectionString);
//使用Command之前一定要先打开连接,后关闭连接,而DataAdapter则会自动打开关闭连接
myConnection.Open();
SqlCommand tempSqlCommand = new SqlCommand(tempStrSQL, this.myConnection);
int intNumber = tempSqlCommand.ExecuteNonQuery();//返回数据库中影响的行数
myConnection.Close();
return intNumber;
}
}
}
blic partial class MainFrm : Form
{
private DataSet ds = new DataSet();
private LinkDataBase link = new LinkDataBase();
private string sendTableName = "权限清单";
private string sendStrSQL;

//private System.Windows.Forms.MenuStrip mainMenu1;
//private System.Windows.Forms.MenuItem menuItem1;
//private System.Windows.Forms.MenuItem mnu_WareDataManage;
//private System.Windows.Forms.MenuItem mnu_StokerDataManage;

//private System.Windows.Forms.MenuItem mnu_StorageSearch;
//private System.Windows.Forms.MenuItem mnu_PopedomManage;
//private System.Windows.Forms.MenuItem mnu_SellTable;

public MainFrm()
{
InitializeComponent();
//this.menuItem1 = new System.Windows.Forms.MenuItem();
//this.mnu_WareDataManage = new System.Windows.Forms.MenuItem();

}


private void menuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
{

}

private void MainFrm_Load(object sender, EventArgs e)
{
this.statusStrip1.Text = "当前用户:" + LoginFrm.strUser + "所属部门:" + LoginFrm.strDepartment;
this.sendStrSQL = "SELECT 权限名称 from 权限清单 where 用户编号='" + LoginFrm.strUser + "'";
this.ds = this.link.SelectDataBase(sendStrSQL, sendTableName);
if (LoginFrm.strDepartment == "系统管理")
{
this.mnu_WareDataManage.Enabled = true;
//this.mnu_StokerDataManage.Enabled = true;
this.mnu_ClientDataManage.Enabled = true;
this.mnu_StockTable.Enabled = true;
this.mnu_SellTable.Enabled = true;
this.mnu_StorageSearch.Enabled = true;
this.mnu_PopedomManage.Enabled = true;
}
else
{

for (int intCounter = 0; intCounter < this.ds.Tables[0].Rows.Count; intCounter++)
{
if (this.ds.Tables[0].Rows[intCounter][0].ToString().Trim() == "商品资料维护")
{
this.mnu_WareDataManage.Enabled = true; continue;
}
if (this.ds.Tables[0].Rows[intCounter][0].ToString().Trim() == "供货商信息维护")
{
this.mnu_StokerDataManage.Enabled = true; continue;
}
if (this.ds.Tables[0].Rows[intCounter][0].ToString().Trim() == "客户信息维护")
{
this.mnu_ClientDataManage.Enabled = true; continue;
}
if (this.ds.Tables[0].Rows[intCounter][0].ToString().Trim() == "进货单")
{
this.mnu_StockTable.Enabled = true; continue;
}
if (this.ds.Tables[0].Rows[intCounter][0].ToString().Trim() == "销售单")
{
this.mnu_SellTable.Enabled = true; continue;
}
if (this.ds.Tables[0].Rows[intCounter][0].ToString().Trim() == "库存查询")
{
this.mnu_StorageSearch.Enabled = true; continue;
}
if (this.ds.Tables[0].Rows[intCounter][0].ToString().Trim() == "权限管理")
{
this.mnu_PopedomManage.Enabled = true; continue;
}
}
}
}
}
}

2006-09-22 16:13
live41
Rank: 10Rank: 10Rank: 10
等 级:贵宾
威 望:67
帖 子:12442
专家分:0
注 册:2004-7-22
收藏
得分:0 
this.sendStrSQL = "SELECT 权限名称 from 权限清单 where 用户编号='" + LoginFrm.strUser + "'";


MessageBox.show(sendStrSQL); //看看这句有没有错先吧!
2006-09-22 16:21
live41
Rank: 10Rank: 10Rank: 10
等 级:贵宾
威 望:67
帖 子:12442
专家分:0
注 册:2004-7-22
收藏
得分:0 
我估计是 = 号的问题,

还有,以后表名和字段名最好用英文,因为有时有些操作系统是不兼容的,
2006-09-22 16:22
yjh633
Rank: 1
等 级:新手上路
帖 子:33
专家分:0
注 册:2006-3-11
收藏
得分:0 
搞定....谢谢...是等号的问题...
2006-09-22 16:41
快速回复:[求助]找不出错在哪里...
数据加载中...
 
   



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

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