- 浏览: 727398 次
- 性别:
- 来自: 上海
文章分类
- 全部博客 (419)
- 杂软粉墨 (2)
- 创意灵感 (3)
- 经验记录 (137)
- 开源轨迹 (2)
- sip-communicator (2)
- 闲侃杂谈 (8)
- 问题交流 (24)
- 概念模式 (32)
- 难点备案 (5)
- JwChat (1)
- 中国象棋 (1)
- 教育探索 (6)
- 英语研究 (58)
- 星际争霸 (1)
- 电信知识 (1)
- 软件架构 (3)
- 哲学探索 (26)
- 算法灵魂 (8)
- 近视探索 (6)
- 数学数学 (3)
- 牛角钻尖 (23)
- 至强文言 (3)
- 数据结构 (1)
- 宇宙物理 (2)
- 网络架构 (3)
- 游戏领域 (4)
- 图形处理 (2)
- 修炼之路 (8)
- 读书天地 (20)
- 编解乱码 (2)
- 概念探索 (8)
- 格物致知 (1)
- 其它语言 (1)
- 测试领域 (3)
- 文化风流 (1)
- JQuery (1)
- 網頁領域 (1)
- Unix/Linux (1)
- Inside JVM (1)
- 异常分析 (1)
最新评论
-
suyujie:
引用
HTML <a> 标签灰显禁用 -
suyujie:
HTML <a> 标签灰显禁用 -
suyujie:
HTML <a> 标签灰显禁用 -
suyujie:
HTML <a> 标签灰显禁用 -
iamzhoug37:
您能说一下"局部变量不受文本顺序限制" 是 ...
声明前为什么能赋值却不能输出,都是使用
once upon a time, i came upon one thing that my c# program cannot access its specified database which sql server 2008. i dont know why, at my point of view, the program works well for sql server 2000, now it doesn't work for 2008, it's mainly supposed to be the cause of the new database, maybe they have different connection ways. At the thought of this, i began to search a lot about how to connect to 2008, with a result you can imagine, all failed. my class design is like the follows:
public class Service : System.Web.Services.WebService { private static string connectionString = ""; [WebMethod] public string WebserviceCrud(string strxml) { //connectionString = "SERVER=" + databaseip + "," + databaseport + ";DATABASE=" + databasename + ";Uid=" + userid + ";pwd=" + password; //connectionString = "Data Source=" + databaseds + "," + databaseport + ";Initial Catalog=" + databasename + ";Persist Security Info=True;User Id=" + userid + ";Password=" + password + ";"; connectionString = "data source=" + databaseds + ";initial catalog=" + databasename + ";user id=" + userid + ";password=" + password + ";"; return InvokeMethod(methodname, mParam); } public string InvokeMethod(string methodname, object[] mParam) { // Create MyClass object Service myClassObj = new Service(); // Get the Type information. Type myTypeObj = myClassObj.GetType(); // Get Method Information. MethodInfo myMethodInfo = myTypeObj.GetMethod(methodname); return (string)myMethodInfo.Invoke(myClassObj, mParam); } public string RequestUserQuery(string parameters) { string username = xmlhandle.GetNodeContent(parameters, "/Params/UserId"); string commandText = "SELECT STAFF_ID as StaffId, isnull(STAFF_NAME, 'null') as StaffName, isnull(JOB, 'null') as Job, DEPT_NO as DeptNo FROM WHS_STAFF WHERE LOGIN_USERNAME = '" + username +"'"; DataSet ds = OnlineShop.Database.SqlHelper.ExecuteDataset(connectionString, CommandType.Text, commandText); string xml = ds.GetXml(); xml = xml.Replace("<NewDataSet>", "<Results>"); xml = xml.Replace("</NewDataSet>", "</Results>"); xml = xml.Replace("<Table>", ""); xml = xml.Replace("</Table>", ""); return GenerateResponseXml("ResponseUserQuery", xml); } }
as you see, the connectionString's not static at the first place, so with every call of webmethod, it creates every new object, thus every new member field connectionString, even though i've changed its value, it's just acts as if it didn't change at all, it holds the original value from its declaration.
why can't i find this error? i concluded it's all from mindset . as i dont think the other part may have errors. as it just has been working fine before, cause i forgot the truth i ever modifed it the day before but i didn't check it through. it's really a lesson which deserves to be tight remembered.
发表评论
-
关于方法访问控制符protected
2012-11-29 10:38 1196http://bbs.csdn.net/topics/3902 ... -
一个基本问题关于引用的
2012-05-15 10:20 1073问: int a = 1; Integer b = new ... -
我對面向對象和過程的理解。
2012-05-02 08:30 1006我的一些理解。 面向过程,是对客观现象的描述,感觉是有一个上 ... -
stack and heap
2012-01-13 23:17 1007我觉得是根据应用方式 和本身特性 才将内存分区的,目的是提 ... -
program experience conclusion
2011-07-11 15:35 10111. check parameters for validit ... -
PreparedStatement's possible designated parameter
2011-04-29 13:45 934though it's nearly impossible t ... -
clean Log4j
2011-04-12 11:19 1022import org.apache.log4j.BasicCo ... -
about abstract class
2011-04-02 10:34 804yes, we do know abstract class ... -
cvs operations on linux
2011-03-25 09:40 955http://www.linuxhowtos.org/Syst ... -
regex to exchange two parts
2011-03-24 17:09 1006public class Test { public ... -
About the database locking
2011-03-09 11:02 899http://en.wikipedia.org/wiki/Lo ... -
how to send soap message in java
2011-03-08 10:29 1851import java.io.BufferedReader; ... -
About ShutDownDemo
2011-03-07 15:02 918public class ShutdownDemo { p ... -
How do you know if an explicit object casting is needed
2011-02-24 16:33 1117通俗来讲,不可能将一只是猫的动物强转为狗 再说Graphic ... -
有关MimeUtility
2011-02-24 13:11 3292import java.io.UnsupportedEncod ... -
Shadowing, Overriding, Hiding and Obscuring
2011-02-22 15:15 1094当子类属性与父类属性重叠时 这种叫法上是shadowi ... -
JAXP usage
2011-02-16 16:07 1049import java.io.ByteArrayInputSt ... -
运行一个类,如果classpath中路径带空格就加双引号
2011-02-11 11:25 2760注意是这样加: java -cp .;"d:\my ... -
关于ClassPath中的current directory
2011-01-28 16:40 1113Given: 1. package com.company. ... -
文件内容操作batch
2011-01-27 16:36 1159I've learnt it from csdn qybao( ...
相关推荐
ASP.NET 2.0+SQL Server 2005全程指南 目录 基础篇 第1章 ASP.NET概述及环境配置 1.1 认识ASRNET 1.1.1 .NET Framework框架 1.1.2 ASP.NET功能与特性 1.1.3 ASP.NET与ASP的区别 1.2 搭建ASP.NET开发环境 1.2.1...
案例12 连接SQL Server数据库 本章小结 第5章 Visual C#2008的SQL查询与图表技朮 案例1 多表连接条件查询 案例2 分组条件查询 案例3 排序查询 案例4 嵌套查询 案例5 视图在Select查询语句中的应用 案例6 ...
将数据从SQL Server传输到Postgres的一种方法是在数据库之间建立链接服务器,然后... 有关更多信息,请参见:http://msdn.microsoft.com/zh-cn/library/ms188279.aspx[^]另一件事是SQL Server 2008 Express具有大小...
我想指出一件事。 如果不确定使用哪个编码代码页,请检查此并查找它。 代码页默认值为65001,这是UTF-8编码的代码页。 如果您对改进该工具有任何建议,或者发现错误或其他问题,请发表评论,我们将很高兴对其进行...
C#编程经验技巧宝典源代码,目录如下: 第1章 开发环境 1 <br>1.1 Visual Studio开发环境安装与配置 2 <br>0001 安装Visual Studio 2005开发环境须知 2 <br>0002 配置合适的Visual Studio 2005...
实例127 使用odbc dsn连接sql server数据库 实例128 使用ado.net对象录入数据 实例129 利用存储过程录入数据 实例130 使用oledbdatareader读取文本文件的内容 实例131 使用sqldatareader读取用户登录信息 实例132 ...
书中沿袭深受读者欢迎的step by step风格,通过丰富的练习引导读者逐步构建windows应用程序,访问sql server数据库,开发asp.net web应用程序,创建并使用web服务等。 全书共29章,结构清晰,叙述清楚。所有练习均...
2、开发环境为Visual Studio 2012,数据库为SQL Server 2008R2,数据库文件在DB文 件夹(并且附有sql2008脚本文件)中,使用.net 4.5开发。 3、默认数据库连接字符串在webconfig配置文件中修改。 4、该源码比较适合...
持sqlserver,oracle等多种数据,开放API接口,可以通过开发API直接集成到现有的办公系统中。 1、将下载包中的fcbill.rar解压出来,将其中的fcbill目录在C:Inetpubwwwroot目录下 (假如你的IIS装在C:下),即C:...
所谓事务,就是把多件事情当做一件事情来处理。也就是大家同在一条船上! 由一个事务来完成多个表的同步操作,要么都执行成功,要么都不成功.下面举个例子,用C#实现Access数据库事务的处理方法: 向一个表提交数据...
为克服现有方法存在的不足,在Visual Studio 2010环境下,基于C#编程语言,开发了一个针对SQL Server数据库表结构的报表生成系统。该系统支持单表导出和批量导出两种工作模式,支持将表结构导出到Word和Excel两种...
该源码系统为某汽车维修厂维修系统 二、功能介绍 主要功能为维修单据的录入、查询,以及会员卡管理、多种结账方式 并结合RDLC进行结账单打印。... 1、开发环境为Visual Studio 2008,数据库为SQL Server 2005
在系统设计过程中,我体会到了即使是一件小事也不能马虎,在设计之前一定要对所设计的系统有较为深刻地了解,并对用户的要求加以认真的分析,并给予分类,对所分类进行功能模块化设计,画出系统数据流图,流程图和结构图....
在系统设计过程中,我体会到了即使是一件小事也不能马虎,在设计之前一定要对所设计的系统有较为深刻地了解,并对用户的要求加以认真的分析,并给予分类,对所分类进行功能模块化设计,画出系统数据流图,流程图和结构图....
Visual Studio可以不打开,SqlServer Management Studio可以不打开,但是SqlServer服务却默认开启了。下班后,我的计算机想用于生活、娱乐,不需要数据库服务这些东西,尤其是在安装了Oracle数据库后,我感觉机器...
Visual Studio可以不打开,SqlServer Management Studio可以不打开,但是SqlServer服务却默认开启了。下班后,我的计算机想用于生活、娱乐,不需要数据库服务这些东西,尤其是在安装了Oracle数据库后,我感觉机器...