2009年06月10日

     今天看了本书<<鱼>>,讲的是如何将乏味的工作变的有趣.摘录其中的要点.

   选择自己的态度---我觉得我们这一点上已有一个好的开端.员工们的菜单是很了不起的注意,这是真正进步的迹象.要是不选择则自己的态度,其他的都是在浪费时间.我需要继承探索和扩大我么对这个因素的认识.

   玩---鱼市是一个成年人的游戏场所.如果卖鱼的人在卖鱼的时候可以这么开心,我们第一担保公司就有希望做到.

   让别人快乐---一定要福利顾客一起玩,气氛才会热烈.不能像我在洛杉几的老板,总跟着录音机一样对我说话,让我从来没有享受到工作的乐趣.

   投入---卖鱼的人都是全身心的投入.他们没有心不在焉或在打电话.他们盯着来往的人群,热气地招呼客人.他们与我聊天,就像是长时间没有见面的朋友.

2009年05月18日

        新一代系统上线了!今天我回部门上班了,又回到无源这个大集体.我称之为"归队".

         自年初调到公司组成的FIS临时研发小组至今,已有好长的一段时间没有写BLOG了.今天来留点吧.研发小组工作比部门要忙许多,但更富有挑战性!总的的来说,在这段时间里,又有了很大的进步.

         临时小组,这个矩阵式的组织结构发挥了它应有的优势,效率相对来说还是比较高的.因为遇到问题我们可以马上询问身边的同事,或请求帮助,或共同探讨,可以很快的得到解决方案.而且能使用同事开发的功能,复用他们已经编写的代码,真正作到面向对象开发系统.其实,是没有太多的管理层次,除外项目小组组长,其他同事都是一个级别,沟通起来相当方便.在这里,深深的体会到团队合作的优势.

         小组的同事来自不同部门,和他们在一起工作,可以见识到不同的思维模式,更直接的说就是不同的编程习惯和开发模式.比较中,可以见证高效的开发.借鉴了他们的开发经验,学习到他们优秀的编程习惯.

          新一代系统真正做到了三层模式的架构,类似MVC开发模式.实现了低偶合,可测试,高重用和可试用,还有利于维护和管理.对大型项目的开发经验的积累又有了新的源泉积累.

          合作的友谊是美好的.那次爬山活动,让人回味.平常埋头写代码的沉默寡言的同事也很活跃好动.也有对人的热枕和对生活的激情.

    

2009年03月18日

          今天接着尝试应用存储过程,实现使用存储过程修改数据.要求判断是否修改成功.

存储过程的定义需要增加些新内容了,因为要在应用程序执行存储过程时判断是否成功.

存储过程如下:
drop proc UpdateUserInfo

create proc UpdateUserInfo
@NAME varchar(20),
@AGE int,
@ID varchar(10)
AS
declare @error int  //声明一个变量,
update dbo.authors set author =@NAME,age =@AGE  //修改姓名和年龄
where authorid=@ID 
set @error=@@error  //把系统定义的变量值赋给声明的变量
select  @error  as error //执行存储过程时,返回执行结果值, 0表示没有错误,成功修改

C#后台代码:
private bool UpdateUserInfo(string name ,string age,string id)
    {
        bool booResult = false;
        SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["myconn"].ToString());
        SqlCommand cmd = new SqlCommand("UpdateUserInfo",conn);
        cmd.CommandType = CommandType.StoredProcedure;
        SqlParameter paraName = new SqlParameter("@NAME",SqlDbType.VarChar,20);
        paraName.Value = name;
        cmd.Parameters.Add(paraName);
        SqlParameter paraAge = new SqlParameter("@AGE", SqlDbType.Int, 4);
        paraAge.Value = int.Parse(age);
        cmd.Parameters.Add(paraAge);
        cmd.Parameters.Add("@ID",id);//提示过期,但可以正常使用
        try
        {
            conn.Open();
            int res =(Int32) cmd.ExecuteScalar();//执行存储过程返回结果值
            conn.Close();
            if(res==0) //表示成功执行
            {
                booResult= true;
            }
            return  booResult;
        }catch(Exception ex)
        {
            conn.Close();
            Response.Write(ex.ToString());
            return booResult;
        }

 

2009年03月17日

         学习了基本的编程知识,能实现初层次的功能后,逐步向高层次学习.技术活不学习就落后.

         今天听同事说到需要应用存储过程,要我帮忙写一个.记得学校学习数据库SQL2000时,有学习过,在其中的课程设计中也编写过.但都是在数据库查询分析器编写和使用,毕竟没有应用到应用程序上.

          刚好可以学习应用存储过程到实际中.首先了解它的优、缺点。

存储过程优点:

     * 存储过程的能力大大增强了SQL语言的功能和灵活性。存储过程可以用流控制语句编写,有很强的灵活性,可以完成复杂的判断和较复杂的 运算。
  * 可保证数据的安全性和完整性。
     # 通过存储过程可以使没有权限的用户在控制之下间接地存取数据库,从而保证数据的安全。
     # 通过存储过程可以使相关的动作在一起发生,从而可以维护数据库的完整性。
  * 在运行存储过程前,数据库已对其进行了语法和句法分析,并给出了优化执行方案。这种已经编译好的过程可极大地改善SQL语句的性能。由于执行SQL语句的大部分工作已经完成,所以存储过程能以极快的速度执行。
  * 可以降低网络的通信量。
  * 使体现企业规则的运算程序放入数据库服务器中,以便:
     # 集中控制。
     # 当企业规则发生变化时在服务器中改变存储过程即可,无须修改任何应用程序。企业规则的特点是要经常变化,如果把体现企业规则的运算程序放入应用程序中,则当企业规则发生变化时,就需要修改应用程序工作量非常之大(修改、发行和安装应用程序)。如果把体现企业规则的运算放入存储过程中,则当企业规则发生变化时,只要修改存储过程就可以了,应用程序无须任何变化。

缺点:1:调试麻烦,但是用 PL/SQL Developer 调试很方便!弥补这个缺点。
      2:移植问题,数据库端代码当然是与数据库相关的。但是如果是做工程型项目,基本不存在移植问题。
      3:重新编译问题,因为后端代码是运行前编译的,如果带有引用关系的对象发生改变时,受影响的存储过程、包将需要重新编译(不过也可以设置成运行时刻自动编译)。
      4: 如果在一个程序系统中大量的使用存储过程,到程序交付使用的时候随着用户需求的增加会导致数据结构的变化,接着就是系统的相关问题了,最后如果用户想维护该系统可以说是很难很难、而且代价是空前的。维护起来更加麻烦!

          我的第一个存储过程应用:

          首先,在数据库里建立存储过程,名称为:QueryAuthorsInfo

         drop proc QueryAuthorsInfo
         //创建前先
       CREATE PROC QueryAuthorsInfo
       @AUTHORID varchar(20) ,
       AS
       select authorid,author,(age+10) as age,birthdate from dbo.authors  where authorid=@AUTHORID

           然后,aspx页面定义方法,返回用户信息表中的用户信息,参数是用户信息记录ID。

    public DataTable GetUserInformation(string id)
       {
        DataSet objds = new DataSet(); 
        SqlConnection objconn = new SqlConnection(ConfigurationManager.ConnectionStrings["conn"].ToString());
        SqlDataAdapter objda = new SqlDataAdapter("QueryAuthorsInfo", objconn);
         //QueryAuthorsInfo  是数据库中建立的存储过程名称
        objda.SelectCommand.CommandType = CommandType.StoredProcedure;
        //指明使用存储过程
        SqlParameter paraID = new SqlParameter("@AUTHORID", SqlDbType.VarChar, 20);
        objda.SelectCommand.Parameters.Add(paraID);
        objda.SelectCommand.Parameters["@AUTHORID"].Value = id;
        // 添加参数,并赋值
        try
        {
            objconn.Open();
            objda.Fill(objds);
            objconn.Close();
            return objds.Tables[0];
        }
        catch(Exception ex)
        {
            Response.Write(ex.ToString());
            return null;

         }
   
     }

 

         

2009年03月07日

       今天在做ASP.NE程序时,要实现dataset主从表嵌套.进行主表筛选时出现"不能启用此约束,因为不是所有的值都具有相应的父值  "错误提示.

       代码如下:灰色行出现错误提示,后来GOOGLE结果是需要在Add()方法内添加一个参数false.  

  private PagedDataSource GetBookInfo()
    {
        string strConnection = ConfigurationManager.ConnectionStrings["myconn"].ConnectionString;
        SqlConnection conn = new SqlConnection(strConnection);
        SqlDataAdapter sda = new SqlDataAdapter("select * from books",conn);
        DataSet ds = new DataSet();
        sda.Fill(ds,"books");
        SqlDataAdapter sda2 = new SqlDataAdapter("select * from authors", conn);
        sda2.Fill(ds, "authors");
        ds.Relations.Add("myrela", ds.Tables["books"].Columns["tableid"], ds.Tables["authors"].Columns["tableid"]);
        PagedDataSource pds = new PagedDataSource();
        pds.DataSource = ds.Tables["books"].DefaultView;
        pds.AllowPaging = true;
        pds.PageSize = 3;
        pds.CurrentPageIndex = Convert.ToInt32(Request.QueryString["page"]);
        return pds;
    }

        这句话的意民是,子表的数据不是每一个值在主表中都有相联系的值。正常情况下不作主表筛选时,可以很正常的显示,如果对主表删除数据,OR主表筛选时,比方说把主表中日期为2007-03-27进行筛选时,那就会出现 不能启用此约束,因为不是所有的值都具有相应的父值的错误因为子表中的ID表比主表中的ID值多,所以就会出现这样的错误.

       灰色行改成如下就OK!

      ds.Relations.Add("myrela", ds.Tables["books"].Columns["tableid"], ds.Tables["authors"].Columns["tableid"], false);

 

2009年02月25日

        今天想要实现一个简单的功能:将 gridview 的数据导出,生成一个Excel文件.但是遇到了问题.错误提示:类型“GridView”的控件“gvShowExcel”必须放在具有 runat=server 的窗体标记内。

       代码如下:

       //定义文档类型、字符编码
        Response.Clear();
        Response.Buffer = true;
        Response.Charset = "GB2312";
        //下面这行很重要, attachment 参数表示作为附件下载,您可以改成 online在线打开
        //filename=FileFlow.xls 指定输出文件的名称,注意其扩展名和指定文件类型相符,可以为:.doc    .xls    .txt   .htm
        Response.AppendHeader("Content-Disposition", "attachment;filename=FileFlow.xls");
        Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");////Response.ContentEncoding=System.Text.Encoding.UTF8;//System.Text.Encoding.GetEncoding("GB2312");
        //Response.ContentType指定文件类型 可以为application/ms-excel、application/ms-word、application/ms-txt、application/ms-html 或其他浏览器可直接支持文档
        Response.ContentType = "application/ms-excel";
        this.EnableViewState = false;
        // 定义一个输入流
        System.IO.StringWriter oStringWriter = new System.IO.StringWriter();
        System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);

        string strExcelPath = Server.MapPath(".") + @"\App_Data\ExcelFile.xls";
        string strSqlA = "SELECT  源单单号,物料长代码 FROM [Sheet1$] order by 编号";
        ReadExcelFile getExcel = new ReadExcelFile();
        gvShowExcel.DataSource = getExcel.GetExcelFile(strExcelPath, strSqlA);
        gvShowExcel.DataBind();

         在百度后,终于找到了解决方法.在页面加载时,重载一个方法: 
         public override void VerifyRenderingInServerForm(Control control)
          {
              //不需要添加内容
         }

          这样就好了!

2009年02月18日

         大学学习管理学时曾学习了一种组织结构叫做矩阵式管理结构.它有优势也有劣势.优势是组织中的成员能灵活地安排和完成组织的任务,对环境反应相当灵活,能迅速及时的处理遇到的问题.劣势在于多头领导,让组织成员疲于奔命,使工作杂乱,影响工作效率.容易产生磨察.该中类型的组织结构要运用的好,需要组织的成员有较好的能力.

          今次参加了公司临时组成的2代系统开发小组其实就是一个矩阵式组织结构.人员从各个部门调动过来,为完成2代系统尽快上线而成为一个小组.

          该出现的问题果然出现了:我们刚要搬去新办公室的时候部门工程经理就跑过来下命令:你们到那边也要完成这里的工作的啊! 这就涉及到工作的优先级了,究竟是先完成临时小组的任务呢还是原来部门的任务呢? 使人捉拿不定.

         完成临时小组的任务效率还蛮高的,大家都知道来这里的目的.所以只要有人提出问题,很多人都很热心的说出自己知道的,并且给出建议,提问题的人可以很快的找到解决方案,很快就完成任务.

         临时小组让人没有一种归属感,都知道两三个月后就解散了,又要回到原来的状态.所以对组织的概念很淡薄.

          矩阵式管理结构成员的纪律相对来说会松散一些,没有直接领导的管束,并且都感觉到有一种更多的自主权力.

           公司高层领导会经常巡逻察看临时小组,冷不丁他就出现在门口,所以成员得警惕三分.

2009年02月01日

        时间好快呀!不知觉就工作了半年了,现在对这半年C#程序员工作做下总结.

        学校时候,积累了点ASP和JAVA经验,工作使用的是C#,所以细节的知识用不上了.然系统开发的理念,开发的方法,代码编写的规范,对工作能力的提升还是有帮助的.

       老大给的第一个项目是华为公司的采购经理提的需求.多个产品 包装在一个箱子出货时,条码枪扫其中一个产品的条码就可以带出所有产品的信息. 当时用了一个字段记录产品对应关系,扫条码时,找到相同关系的就带出来.很简单,很容易实现.

     从老大给的第一个项目开始至今,已经做了几十个项目了.但都很小,也不完整.其中有一个是个独立完整的—看板系统.(未完)

      从这些项目经历中,学会了几大块技术.数据连接,独立类的编写,.net一些常用控件的使用,AJAX无刷新回传技术,线程的使用,定时刷新技术等等.

      新年初,我正想更多地接受部门的项目时,遇上了个锻炼的好机会.公司要求提前上2代系统而需要从部门调出两个参与开发,老大派我和一个有两年开发经验的同事前去.我可以学习更多东西了.

2009年01月06日

    

  •  SQL Server
  •  Access
  •  Oracle
  •  MySQL
  •  Interbase
  •  IBM DB2
  •  Sybase
  •  Informix
  •  Ingres
  •  Mimer SQL
  •  Lightbase
  •  PostgreSQL
  •  DSN
  •  Firebird
  •  Excel
  •  Text
  •  DBF / FoxPro
  •  AS/400
  •  Exchange
  •  Visual FoxPro
  •  Pervasive
  •  UDL
    •  ODBC
    •  OLE DB, OleDbConnection (.NET)
    •  SqlConnection (.NET)
    •  Data Shape
    •  Read more
      •  Standard Security:
        "Driver={SQL Server};Server=Aron1;Database=pubs;Uid=sa;Pwd=asdasd;"
      •  Trusted connection:
        "Driver={SQL Server};Server=Aron1;Database=pubs;Trusted_Connection=yes;"
      •  Prompt for username and password:
        oConn.Properties("Prompt") = adPromptAlways
        oConn.Open "Driver={SQL Server};Server=Aron1;DataBase=pubs;"

      •  Standard Security:
        "Provider=sqloledb;Data Source=Aron1;Initial Catalog=pubs;User Id=sa;Password=asdasd;"
      •  Trusted Connection:
        "Provider=sqloledb;Data Source=Aron1;Initial Catalog=pubs;Integrated Security=SSPI;"
        (use serverName\instanceName as Data Source to use an specifik SQLServer instance, only SQLServer2000)

      •  Prompt for username and password:
        oConn.Provider = "sqloledb"
        oConn.Properties("Prompt") = adPromptAlways
        oConn.Open "Data Source=Aron1;Initial Catalog=pubs;"
      •  Connect via an IP address:
        "Provider=sqloledb;Data Source=190.190.200.100,1433;Network Library=DBMSSOCN;Initial Catalog=pubs;User ID=sa;Password=asdasd;"
        (DBMSSOCN=TCP/IP instead of Named Pipes, at the end of the Data Source is the port to use (1433 is the default))

      •  Standard Security:
        "Data Source=Aron1;Initial Catalog=pubs;User Id=sa;Password=asdasd;"
           - or -
        "Server=Aron1;Database=pubs;User ID=sa;Password=asdasd;Trusted_Connection=False"
           (booth connection strings produces the same result)
      •  Trusted Connection:
        "Data Source=Aron1;Initial Catalog=pubs;Integrated Security=SSPI;"
           - or -
        "Server=Aron1;Database=pubs;Trusted_Connection=True;"
           (booth connection strings produces the same result)
        (use serverName\instanceName as Data Source to use an specifik SQLServer instance, only SQLServer2000)

      •  Connect via an IP address:
        "Data Source=190.190.200.100,1433;Network Library=DBMSSOCN;Initial Catalog=pubs;User ID=sa;Password=asdasd;"
        (DBMSSOCN=TCP/IP instead of Named Pipes, at the end of the Data Source is the port to use (1433 is the default))

      •  Declare the SqlConnection:
        C#:
        using System.Data.SqlClient;
        SqlConnection oSQLConn = new SqlConnection();
        oSQLConn.ConnectionString="my connectionstring";
        oSQLConn.Open();

        VB.NET:
        Imports System.Data.SqlClient
        Dim oSQLConn As SqlConnection = New SqlConnection()
        oSQLConn.ConnectionString="my connectionstring"
        oSQLConn.Open()

      •  MS Data Shape
        "Provider=MSDataShape;Data Provider=SQLOLEDB;Data Source=Aron1;Initial Catalog=pubs;User ID=sa;Password=asdasd;"
        Want to learn data shaping? Check out 4GuyfFromRolla’s great article about Data Shaping >>

      •  How to define which network protocol to use
        • Example:
          "Provider=sqloledb;Data Source=190.190.200.100,1433;Network Library=DBMSSOCN;Initial Catalog=pubs;User ID=sa;Password=asdasd;"

          Name Network library
          dbnmpntw Win32 Named Pipes
          dbmssocn Win32 Winsock TCP/IP
          dbmsspxn Win32 SPX/IPX
          dbmsvinn Win32 Banyan Vines
          dbmsrpcn Win32 Multi-Protocol (Windows RPC)

          Important note!
          When connecting through the SQLOLEDB provider use the syntax Network Library=dbmssocn
          and when connecting through MSDASQL provider use the syntax Network=dbmssocn

      •  All SqlConnection connectionstring properties
        • This table shows all connectionstring properties for the ADO.NET SqlConnection object. Most of the properties are also used in ADO. All properties and descriptions is from msdn.

          Name Default Description
          Application Name   The name of the application, or ‘.Net SqlClient Data Provider’ if no application name is provided.
          AttachDBFilename
          -or-
          extended properties
          -or-
          Initial File Name
            The name of the primary file, including the full path name, of an attachable database. The database name must be specified with the keyword ‘database’.
          Connect Timeout
          -or-
          Connection Timeout
          15 The length of time (in seconds) to wait for a connection to the server before terminating the attempt and generating an error.
          Connection Lifetime 0 When a connection is returned to the pool, its creation time is compared with the current time, and the connection is destroyed if that time span (in seconds) exceeds the value specified by connection lifetime. Useful in clustered configurations to force load balancing between a running server and a server just brought on-line.
          Connection Reset ‘true’ Determines whether the database connection is reset when being removed from the pool. Setting to ‘false’ avoids making an additional server round-trip when obtaining a connection, but the programmer must be aware that the connection state is not being reset.
          Current Language   The SQL Server Language record name.
          Data Source
          -or-
          Server
          -or-
          Address
          -or-
          Addr
          -or-
          Network Address
            The name or network address of the instance of SQL Server to which to connect.
          Enlist ‘true’ When true, the pooler automatically enlists the connection in the creation thread’s current transaction context.
          Initial Catalog
          -or-
          Database
            The name of the database.
          Integrated Security
          -or-
          Trusted_Connection
          ‘false’ Whether the connection is to be a secure connection or not. Recognized values are ‘true’, ‘false’, and ’sspi’, which is equivalent to ‘true’.
          Max Pool Size 100 The maximum number of connections allowed in the pool.
          Min Pool Size 0 The minimum number of connections allowed in the pool.
          Network Library
          -or-
          Net
          ‘dbmssocn’ The network library used to establish a connection to an instance of SQL Server. Supported values include dbnmpntw (Named Pipes), dbmsrpcn (Multiprotocol), dbmsadsn (Apple Talk), dbmsgnet (VIA), dbmsipcn (Shared Memory) and dbmsspxn (IPX/SPX), and dbmssocn (TCP/IP).
          The corresponding network DLL must be installed on the system to which you connect. If you do not specify a network and you use a local server (for example, "." or "(local)"), shared memory is used.
          Packet Size 8192 Size in bytes of the network packets used to communicate with an instance of SQL Server.
          Password
          -or-
          Pwd
            The password for the SQL Server account logging on.
          Persist Security Info ‘false’ When set to ‘false’, security-sensitive information, such as the password, is not returned as part of the connection if the connection is open or has ever been in an open state. Resetting the connection string resets all connection string values including the password.
          Pooling ‘true’ When true, the SQLConnection object is drawn from the appropriate pool, or if necessary, is created and added to the appropriate pool.
          User ID   The SQL Server login account.
          Workstation ID the local computer name The name of the workstation connecting to SQL Server.

          Note
          Use ; to separate each property.
          If a name occurs more than once, the value from the last one in the connectionstring will be used.
          If you are building your connectionstring in your app using values from user input fields, make sure the user can’t change the connectionstring by inserting an additional property with another value within the user value.

       

    •  ODBC
    •  OLE DB, OleDbConnection (.NET)
      •  Standard Security:
        "Driver={Microsoft Access Driver (*.mdb)};Dbq=C:\mydatabase.mdb;Uid=Admin;Pwd=;"
      •  Workgroup:
        "Driver={Microsoft Access Driver (*.mdb)};Dbq=C:\mydatabase.mdb;SystemDB=C:\mydatabase.mdw;"
      •  Exclusive:
        "Driver={Microsoft Access Driver (*.mdb)};Dbq=C:\mydatabase.mdb;Exclusive=1;Uid=admin;Pwd="

      •  Standard security:
        "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\somepath\mydb.mdb;User Id=admin;Password=;"
      •  Workgroup (system database):
        "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\somepath\mydb.mdb;Jet OLEDB:System Database=system.mdw;"
      •  With password:
        "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\somepath\mydb.mdb;Jet OLEDB:Database Password=MyDbPassword;"

    •  ODBC
    •  OLE DB, OleDbConnection (.NET)
    •  OracleConnection (.NET)
    •  Core Labs OraDirect (.NET)
    •  Data Shape
      •  New version:
        "Driver={Microsoft ODBC for Oracle};Server=OracleServer.world;Uid=Username;Pwd=asdasd;"
      •  Old version:
        "Driver={Microsoft ODBC Driver for Oracle};ConnectString=OracleServer.world;Uid=myUsername;Pwd=myPassword;"

      •  Standard security:
        "Provider=msdaora;Data Source=MyOracleDB;User Id=UserName;Password=asdasd;"
        This one’s from Microsoft, the following are from Oracle

      •  Standard Security:
        "Provider=OraOLEDB.Oracle;Data Source=MyOracleDB;User Id=Username;Password=asdasd;"
      •  Trusted Connection:
        "Provider=OraOLEDB.Oracle;Data Source=MyOracleDB;OSAuthent=1;"

      •  Standard:
        "Data Source=MyOracleDB;Integrated Security=yes;"
        This one works only with Oracle 8i release 3 or later

      •  Specifying username and password:
        "Data Source=MyOracleDB;User Id=username;Password=passwd;Integrated Security=no;"
        This one works only with Oracle 8i release 3 or later

      •  Declare the OracleConnection:
        C#:
        using System.Data.OracleClient;
        OracleConnection oOracleConn = new OracleConnection();
        oOracleConn.ConnectionString = "my connectionstring";
        oOracleConn.Open();

        VB.NET:
        Imports System.Data.OracleClient
        Dim oOracleConn As OracleConnection = New OracleConnection()
        oOracleConn.ConnectionString = "my connectionstring"
        oOracleConn.Open()

        Missing the System.Data.OracleClient namespace? Download .NET Managed Provider for Oracle »

        Great article! "Features of Oracle Data Provider for .NET" by Rama Mohan G. at C# Corner

      •  Standard:
        "User ID=scott; Password=tiger; Host=ora; Pooling=true; Min Pool Size=0;Max Pool Size=100; Connection Lifetime=0"
        Read more at Core Lab and the product page.

      •  MS Data Shape:
        "Provider=MSDataShape.1;Persist Security Info=False;Data Provider=MSDAORA;Data Source=orac;user id=username;password=mypw"
        Want to learn data shaping? Check out 4GuyfFromRolla’s great article about Data Shaping >>

    •  ODBC
    •  OLE DB, OleDbConnection (.NET)
    •  MySqlConnection (.NET)
    •  SevenObjects MySqlClient (.NET)
    •  Core Labs MySQLDirect (.NET)
      •  ODBC 2.50 Local database:
        "Driver={mySQL};Server=localhost;Option=16834;Database=mydatabase;"
      •  ODBC 2.50 Remote database:
        "Driver={mySQL};Server=data.domain.com;Port=3306;Option=131072;Stmt=;Database=my-database;Uid=username;Pwd=password;"
      •  ODBC 3.51 Local database:
        "DRIVER={MySQL ODBC 3.51 Driver};SERVER=localhost;DATABASE=myDatabase;USER=myUsername;PASSWORD=myPassword;OPTION=3;"
      •  ODBC 3.51 Remote database:
        "DRIVER={MySQL ODBC 3.51 Driver};SERVER=data.domain.com;PORT=3306;DATABASE=myDatabase;USER=myUsername;PASSWORD=myPassword;OPTION=3;"

      •  Standard:
        "Provider=MySQLProv;Data Source=mydb;User Id=UserName;Password=asdasd;"

      •  eInfoDesigns.dbProvider:
        "Data Source=server;Database=mydb;User ID=username;Password=pwd;Command Logging=false"
        This one is used with eInfoDesigns dbProvider, an add-on to .NET

      •  Declare the MySqlConnection:
        C#:
        using eInfoDesigns.dbProvider.MySqlClient;
        MySqlConnection oMySqlConn = new MySqlConnection();
        oMySqlConn.ConnectionString = "my connectionstring";
        oMySqlConn.Open();

        VB.NET:
        Imports eInfoDesigns.dbProvider.MySqlClient
        Dim oMySqlConn As MySqlConnection = New MySqlConnection()
        oMySqlConn.ConnectionString = "my connectionstring"
        oMySqlConn.Open()

      •  Standard:
        "Host=server; UserName=myusername; Password=mypassword;Database=mydb;"
        This is a freeware ADO.Net data provider from SevenObjects

      •  Standard:
        "User ID=root; Password=pwd; Host=localhost; Port=3306; Database=test;Direct=true; Protocol=TCP; Compress=false; Pooling=true; Min Pool Size=0;Max Pool Size=100; Connection Lifetime=0"
        Read more at Core Lab and the product page.

    •  ODBC, Easysoft
    •  ODBC, Intersolv
    •  OLE DB, SIBPROvider
      •  Local computer:
        "Driver={Easysoft IB6 ODBC};Server=localhost;Database=localhost:C:\mydatabase.gdb;Uid=username;Pwd=password"
      •  Remote Computer:
        "Driver={Easysoft IB6 ODBC};Server=ComputerName;Database=ComputerName:C:\mydatabase.gdb;Uid=username;Pwd=password"
        Read more about this driver: Easysoft ODBC-Interbase driver >>

      •  Local computer:
        "Driver={INTERSOLV InterBase ODBC Driver (*.gdb)};Server=localhost;Database=localhost:C:\mydatabase.gdb;Uid=username;Pwd=password"
      •  Remote Computer:
        "Driver={INTERSOLV InterBase ODBC Driver (*.gdb)};Server=ComputerName;Database=ComputerName:C:\mydatabase.gdb;Uid=username;Pwd=password"
        This driver are provided by DataDirect Technologies >> (formerly Intersolv)

      •  Standard:
        "provider=sibprovider;location=localhost:;data source=c:\databases\gdbs\mygdb.gdb;user id=SYSDBA;password=masterkey"
      •  Specifying character set:
        "provider=sibprovider;location=localhost:;data source=c:\databases\gdbs\mygdb.gdb;user id=SYSDBA;password=masterkey;character set=ISO8859_1"
      •  Specifying role:
        "provider=sibprovider;location=localhost:;data source=c:\databases\gdbs\mygdb.gdb;user id=SYSDBA;password=masterkey;role=DIGITADORES"
        Read more about SIBPROvider >>


      Read more about connecting to Interbase in this Borland Developer Network article http://community.borland.com/article/0,1410,27152,00.html

    •  OLE DB, OleDbConnection (.NET) from ms
    •  IBM’s OLE DB Provider (shipped with IBM DB2 UDB v7 or above)
    •  ODBC
      •  TCP/IP:
        "Provider=DB2OLEDB;Network Transport Library=TCPIP;Network Address=XXX.XXX.XXX.XXX;Initial Catalog=MyCtlg;Package Collection=MyPkgCol;Default Schema=Schema;User ID=MyUser;Password=MyPW"
      •  APPC:
        "Provider=DB2OLEDB;APPC Local LU Alias=MyAlias;APPC Remote LU Alias=MyRemote;Initial Catalog=MyCtlg;Package Collection=MyPkgCol;Default Schema=Schema;User ID=MyUser;Password=MyPW"

      •  TCP/IP:
        Provider=IBMDADB2;Database=sample;HOSTNAME=db2host;PROTOCOL=TCPIP;PORT=50000;uid=myUserName;pwd=myPwd;

      •  Standard:
        "driver={IBM DB2 ODBC DRIVER};Database=myDbName;hostname=myServerName;port=myPortNum;protocol=TCPIP; uid=myUserName; pwd=myPwd"

    •  ODBC
    •  OLE DB
    •  AseConnection (.NET)
      •  Standard Sybase System 12 (or 12.5) Enterprise Open Client:
        "Driver={SYBASE ASE ODBC Driver};Srvr=Aron1;Uid=username;Pwd=password"
      •  Standard Sybase System 11:
        "Driver={SYBASE SYSTEM 11};Srvr=Aron1;Uid=username;Pwd=password;"
        Do you know a userguide for Sybase System 11, 12, 12.5? E-mail the URL to connectionstrings.com now!! >>

      •  Intersolv 3.10:
        "Driver={INTERSOLV 3.10 32-BIT Sybase};Srvr=Aron1;Uid=username;Pwd=password;"
      •  Sybase SQL Anywhere (former Watcom SQL ODBC driver):
        "ODBC; Driver=Sybase SQL Anywhere 5.0; DefaultDir=c:\dbfolder\;Dbf=c:\mydatabase.db;Uid=username;Pwd=password;Dsn="""""
        Note! The two double quota following the DSN parameter at the end are escaped quotas (VB syntax), you may have to change this to your language specific escape syntax. The empty DSN parameter is indeed critical as not including it will result in error 7778.

        Read more in the Sybase SQL Anywhere User Guide >>

      •  Adaptive Server Anywhere (ASA):
        "Provider=ASAProv;Data source=myASA"
        Read more in the ASA User Guide >>

      •  Adaptive Server Enterprise (ASE) with Data Source .IDS file:
        "Provider=Sybase ASE OLE DB Provider; Data source=myASE"
        Note that you must create a Data Source .IDS file using the Sybase Data Administrator. These .IDS files resemble ODBC DSNs.

      •  Adaptive Server Enterprise (ASE):
        "Provider=Sybase.ASEOLEDBProvider;Srvr=myASEserver,5000;Catalog=myDBname;User Id=username;Password=password"
           - some reports on problem using the above one, try the following as an alternative -

        "Provider=Sybase.ASEOLEDBProvider;Server Name=myASEserver,5000;Initial Catalog=myDBname;User Id=username;Password=password"

        This one works only from Open Client 12.5 where the server port number feature works,燼llowing fully qualified connection strings to be used without defining燼ny .IDS Data Source files.

      •  Standard:
        "Data Source=’myASEserver’;Port=5000;Database=’myDBname’;UID=’username’;PWD=’password’;"
      •  Declare the AseConnection:
        C#:
        using Sybase.Data.AseClient;
        AseConnection oCon = new AseConnection();
        oCon.ConnectionString="my connection string";
        oCon.Open();

        VB.NET:
        Imports System.Data.AseClient
        Dim oCon As AseConnection = New AseConnection()
        oCon.ConnectionString="my connection string"
        oCon.Open()

    •  ODBC
    •  OLE DB
      •  Informix 3.30:
        "Dsn=”;Driver={INFORMIX 3.30 32 BIT};Host=hostname;Server=myserver;Service=service-name;Protocol=olsoctcp;Database=mydb;UID=username;PWD=myPwd
      •  Informix-CLI 2.5:
        "Driver={Informix-CLI 2.5 (32 Bit)};Server=myserver;Database=mydb;Uid=username;Pwd=myPwd"

      •  IBM Informix OLE DB Provider:
        "Provider=Ifxoledbc.2;password=myPw;User ID=myUser;Data Source=dbName@serverName;Persist Security Info=true"

    •  ODBC
      • DSN-less
        "Provider=MSDASQL.1;DRIVER=Ingres;SRVR=xxxxx;DB=xxxxx;Persist Security Info=False;uid=xxxx;pwd=xxxxx;SELECTLOOPS=N;Extended Properties="""SERVER=xxxxx;DATABASE=xxxxx;SERVERTYPE=INGRES""

    •  ODBC
      •  Standard Security:
        "Driver={MIMER};Database=mydb;Uid=myuser;Pwd=mypw;"
      •  Prompt for username and password:
        "Driver={MIMER};Database=mydb;"

    •  Standard
      •  Standard:
        "user=USERLOGIN;password=PASSWORD;UDB=USERBASE;server=SERVERNAME"

    •  Core Labs PostgreSQLDirect (.NET)
      •  Standard:
        "User ID=root; Password=pwd; Host=localhost; Port=5432; Database=testdb;Pooling=true; Min Pool Size=0; Max Pool Size=100; Connection Lifetime=0"
        Read more at Core Lab and the product page.

    •  ODBC
      •  DSN:
        "DSN=myDsn;Uid=username;Pwd=;"
      •  File DSN:
        "FILEDSN=c:\myData.dsn;Uid=username;Pwd=;"

    •  ODBC – IBPhoenix Open Source
    •  .NET – Firebird .Net Data Provider

    •  ODBC
    •  OLE DB
      •  Standard:
        "Driver={Microsoft Excel Driver (*.xls)};DriverId=790;Dbq=C:\MyExcel.xls;DefaultDir=c:\mypath;"

        TIP! SQL syntax: "SELECT * FROM [sheet1$]" – i.e. worksheet name followed by a "$" and wrapped in "[" "]" brackets.

      •  Standard:
        "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\MyExcel.xls;Extended Properties=""Excel 8.0;HDR=Yes;IMEX=1"""
        "HDR=Yes;" indicates that the first row contains columnnames, not data

        "IMEX=1;" tells the driver to always read "intermixed" data columns as text

        TIP! SQL syntax: "SELECT * FROM [sheet1$]" – i.e. worksheet name followed by a "$" and wrapped in "[" "]" brackets.

    •  ODBC
    •  OLE DB
      •  Standard:
        "Driver={Microsoft Text Driver (*.txt; *.csv)};Dbq=c:\txtFilesFolder\;Extensions=asc,csv,tab,txt;"

      •  Standard:
        "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\txtFilesFolder\;Extended Properties=""text;HDR=Yes;FMT=Delimited"""
        "HDR=Yes;" indicates that the first row contains columnnames, not data

    •  ODBC
    •  OLE DB, OleDbConnection (.NET)
      •  standard:
        "Driver={Microsoft dBASE Driver (*.dbf)};DriverID=277;Dbq=c:\mydbpath;"

      •  standard:
        "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\folder;Extended Properties=dBASE IV;User ID=Admin;Password="

    •  OLE DB
    •  ODBC
      •  IBM Client Access OLE DB provider:
        "PROVIDER=IBMDA400; DATA SOURCE=MY_SYSTEM_NAME;Uid=myUserName;Pwd=myPwd"


        Where MY_SYSTEM_NAME is the name given to the system connection in OperationsNavigator

      •  IBM Client Access ODBC driver:
        "Driver={Client Access ODBC Driver (32-bit)};System=my_system_name;Uid=myUserName;Pwd=myPwd"

    •  OLE DB, OleDbConnection (.NET)
    •  ODBC
      •  Database container (.DBC):
        "Provider=vfpoledb.1;Data Source=C:\MyDbFolder\MyDbContainer.dbc;Collating Sequence=machine"
      •  Free table directory:
        "Provider=vfpoledb.1;Data Source=C:\MyDataDirectory\;Collating Sequence=general"
      •  Force the provider to use an ODBC DSN:
        ""Provider=vfpoledb.1;DSN=MyDSN""

        Read more (Microsoft msdn) >>

      •  Database container (.DBC):
        "Driver={Microsoft Visual FoxPro Driver};SourceType=DBC;SourceDB=c:\myvfpdb.dbc;Exclusive=No;NULL=NO;Collate=Machine;BACKGROUNDFETCH=NO;DELETED=NO"
      •  Free Table directory:
        "Driver={Microsoft Visual FoxPro Driver};SourceType=DBF;SourceDB=c:\myvfpdbfolder;Exclusive=No;Collate=Machine;NULL=NO;DELETED=NO;BACKGROUNDFETCH=NO"
        "Collate=Machine" is the default setting, for other settings check the list of supported collating sequences >>


      Microsoft Visual Foxpro site: http://msdn.microsoft.com/vfoxpro

    •  UDL
      •  UDL:
        "File Name=c:\myDataLink.udl;"

    2008年12月28日

           后来找到一个牛人和我要做的事情大概相近,很是激动。http://kenqukii.blog.hexun.com/25481799_d.html
       今天做项目中,由于要异步触发,就是当文本框失去焦点时到数据库去检查一次,然后就想起了三种方式。

    简单介绍下它的用法:

    一.AjaxPro的使用

    1.在项目中添加引用,浏览找到AjaxPro.2.dll文件

    2.在Web.config中的system.web里面写入以下代码
    </configuration>
    <system.web>
      <httpHandlers>
            <add verb="*" path="*.ashx" type="AjaxPro.AjaxHandlerFactory,AjaxPro.2"/>
          </httpHandlers>
    </system.web>
    <//configuration>

    3.在加载事件中,加入
      AjaxPro.Utility.RegisterTypeForAjax(typeof(类名));

    4.写的方法都要用
     [AjaxPro.AjaxMethod]开头,然后在写方法

    5.调用时必须写清楚
     命名空间名.类名.方法,例:WebUI._Default.getData();

    6.调用可分两中方法(同步调用,异步调用)
     
    //在后台写的无参方法
    [AjaxPro.AjaxMethod]
    public string getStr()
    {
            return  "hello my friends";
    }
    //在后台写的有参方法
     [AjaxPro.AjaxMethod]
    public string getString(string str)
    {
         return str + "Say: hello my friends";
    }

    a.同步调用
     (1).拖入html控件button
     (2).双击,自动显示在.aspx的脚本中
     (3).在里面写入你要输入的内容
     例:
    //——————同步调用无参———–
      function Button1_onclick()
      {
             var res=WebUI._Default.getStr();
             alert(res.value);
      }
     
    //——————同步调用有参————
    function Button2_onclick() //TextBox1为服务器控件
    {
        var str=document.getElementById("<%=TextBox1.ClientID%>").value;
        var res=WebUI._Default.getStr(str);
        alert(res.value);
    }

    b.异步调用
     (1).拖入html控件button
     (2).双击,自动显示在.aspx的脚本中
     (3).在里面写入你要输入的内容
     例:
    //—————–异步调用无参—————–
    function Button3_onclick() {
        WebUI._Default.getStr(getStrCallBack);
    }
    function getStrCallBack(res)
    {
        alert(res.value);
    }
    //—————–异步调用有参—————–
    function Button4_onclick() {
        var str=document.getElementById("<%=TextBox1.ClientID %>").value;
        WebUI._Default.getString(str,getStringCallBack);
    }
    function getStringCallBack(res)
    {
        alert(res.value);
    }

    7.调用对象

    //对象
    [AjaxPro.AjaxMethod]
    public Class getClass()
    {
           Class cla = new Class();
           cla.C_Id = 100;
           cla.C_Name = "34班";
           cla.Count = 20;
           return cla;
    }
    //——————同步调用对象———–
    function Button5_onclick() {
        var res=WebUI._Default.getClass().value;
        alert("班级编号:"+res.C_Id+"名称:"+res.C_Name+"人数:"+res.Count);
    }
    //——————异步调用对象———–
    function Button6_onclick() {
        WebUI._Default.getClass(getClassCallBack);
    }
    function getClassCallBack(clas)
    {
        var res=clas.value;
        alert("班级编号:"+res.C_Id+"名称:"+res.C_Name+"人数:"+res.Count);
    }

    8.数据集的使用
     //方法
            [AjaxPro.AjaxMethod]
            public DataSet getInfo()
            {
                return WebUI.GetDataSet.getList();
            }

    //——————–异步调用数据集————–
    function Button8_onclick() {
        WebUI._Default.getInfo(getDataSetCallBack);
    }
    function getDataSetCallBack(res)
    {
        var dataset=res.value;
        var strHtml="";
        strHtml +=’<table  style ="border-collapse:collapse ; border-color:Gray ;"  border="1px">’;
        strHtml +=’        <tr>’;
        strHtml +=’            <td>学生编号</td>’;
        strHtml +=’            <td>名称</td>’;
        strHtml +=’            <td>年龄</td>’;
        strHtml +=’        </tr>’;
       
        for(var i=0;i<dataset.Tables[0].Rows.length;i++)
        {
            strHtml +=’        <tr>’;
            strHtml +=’            <td>’+ dataset.Tables[0].Rows[i].stu_id +’</td>’;
            strHtml +=’            <td>’+ dataset.Tables[0].Rows[i].stu_name +’</td>’;
            strHtml +=’            <td>’+ dataset.Tables[0].Rows[i].stu_age +’</td>’;
            strHtml +=’        </tr>’;
        }
        strHtml +=’    </table>’;
        thedata.innerHTML=strHtml;//thedata是一个<div id="thedata"></div>中的thedata
    }

     

    9.验证码的使用

    //———————-验证码的使用(必须采用同步调用)———————-

    //验证码的使用
    [AjaxPro.AjaxMethod]
    public bool ValidCodeData(string code)
    {
         return (HttpContext.Current.Session["CheckCode"].ToString()==code);
    }

    function Button9_onclick() {
        var code=document.getElementById("<%=TextBox2.ClientID %>").value;
        var bool=WebUI._Default.ValidCodeData(code).value;
        if(bool==true)
        {
            alert("ok");
        }else
        {
            alert("no");
        }
    }
    AjaxPro.dll文件网上很多的,自己下,如果找不到呢,给我发个留言,我发你邮箱

     

    二,直接调用:
    javascript中:<%=后台方法%>
     function says()
        {
            alert("<%=Say()%>");
        }
        function del()
        {
             alert("<%=DeleteByID(8)%>");//DeleteByID(8)后台方法名
        }

    三,采用ICallbackEventHandler回调

    /**//*
     * 对ICallbackEventHandler接口进行声明,要在客户端调用服务端代码而不回发,必须声明该接口并且实现它的两个方法:
     * RaiseCallbackEvent()、GetCallbackResult()
     * RaiseCallbackEvent()的参数是从前台传过来的,根据传来的参数执行不同的代码并将结果用GetCallbackResult()返回前台
    */

    //必须声明System.Web.UI.ICallbackEventHandler接口
    public partial class _Default : System.Web.UI.Page, System.Web.UI.ICallbackEventHandler
    {
        //定义一个回调的返回值
        private string Result;
        //定义两个变量,用来接收页面传过来到操作数
        private string Num1;
        private string Num2;
        protected void Page_Load(object sender, EventArgs e)
        {
           
         }

        /**//// <summary>
        /// 该方法是回调执行的方法,根据参数在这个方法中处理回调的内容,该方法没有返回值
        /// </summary>
        /// <param name="eventArgument">此参数是从客户端传过来的</param>
        public void RaiseCallbackEvent(string eventArgument)
        {
            //eventArgumeng 为javascript从客户端传递的参数,本例传过来三个参数用“/”分割将每个参数取出存入数组
            string[] PagParams = eventArgument.Split(‘/’);
             Num1 = PagParams[1];
             Num2 = PagParams[2];
            //根据第一个参数(所选的操作符),调用不同的执行函数
            switch (PagParams[0])
            {
                case "0":
                     Result = add(); break;
                case "1":
                     Result = sub(); break;
                case "2":
                     Result = multi(); break;
                case "3":
                     Result = division(); break;
             }
         }
       
        /**//// <summary>
        /// 该方法是返回回调的结果给客户端
        /// </summary>
        /// <returns></returns>
        public string GetCallbackResult()
        {
            return Result;
         }

        //一下四个函数是通过RaiseCallbackEvent方法,调用的回调要执行操作的函数
        private string add()
        {
            double addResult = double.Parse(Num1) + double.Parse(Num2);
            return addResult.ToString();
         }

        private string sub()
        {
            double addResult = double.Parse(Num1) – double.Parse(Num2);
            return addResult.ToString();
         }

        private string multi()
        {
            double addResult = double.Parse(Num1) * double.Parse(Num2);
            return addResult.ToString();
         }

        private string division()
        {
            double addresult = double.Parse(Num1) / double.Parse(Num2);
            return addresult.ToString();
         }
    }
          按照这么多的例子,我的第一个Ajax技术还没有实现。问题总是出在HTML中JAVASCRIPT里使用命名空间和类名调用CS文件中的方法时候出错。总提示我的命名空间未定义,我按照比较多人的说发,AjaxPro.dll需要在注册该方法时候写入命名空间.类名,在JAVASCRIPT中引用时候也需要这样调用方法,但是都不成功。重新建立一个项目,仍旧出现这样的问题,只好作罢。看到网上比较多的同行都是使用VS2005来配置AJAX的,而我们公司开发平台还是VS2003。只好晚上回家再弄了。
          开始尝试上面这位牛人的第二中方法。直接在JAVASCRIPT中引用CS中的方法。新建一个实验的页面,虚构一个不带参数的方法:
     

     

    CS页面:
      public string getInfo()
            {   
                string message ="";
                message = name+"你好笨!";
                return message;
            }
       
    ASPX页面:
    <%@ Page language="c#" Codebehind="TestHtml.aspx.cs" AutoEventWireup="false" Inherits="WebLearn.TestHtml" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    <HTML>
     <HEAD>
      <title>TestHtml</title>
      <meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
      <meta content="C#" name="CODE_LANGUAGE">
      <meta content="JavaScript" name="vs_defaultClientScript">
      <meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
     </HEAD>
     <body MS_POSITIONING="GridLayout">
      <form id="Form1" method="post" runat="server">
       <asp:textbox id="txtName" style="Z-INDEX: 102; LEFT: 48px; POSITION: absolute; TOP: 32px" runat="server"
        Height="34px" Width="176px"></asp:textbox><input id="submit" style="Z-INDEX: 101; LEFT: 248px; WIDTH: 64px; POSITION: absolute; TOP: 32px; HEIGHT: 32px"
        onclick="Say()" type="button" value="提交">
       <script language="javascript" type="text/javascript">
      function Say()
      {
           var name= document.getElementById("txtName").value;
           alert(“<%= getInfo()%>”);
      }
       </script>
      </form>
     </body>
    </HTML>

           但是怎么能够将获得的TextBox的值作为参数,然后调用CS中的方法呢?网上大多例子都是没有参数调用的例子。我尝试   alert("<%= getInfo( ‘ "+parameter+"’)%>") 但是不成功。 alert("<%= getInfo( ‘ parameter’)%>"),也不成功。后来想在CS文件方法中直接获得TextBox的值进行处理,然后返回结果。但是CS文件中的方法就是取不到输入的值,只好作罢。
           困难总是有的,可就是阻止不了想前进的心。搜索,再搜索,终于发现了一个好例子。
    CS文件中的方法:
    protected string getMsg(string name)
        {
            return name + " Hello";
        }

    参数给定的方法:
    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="MergeDataTable.aspx.cs" Inherits="MergeDataTable" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>无标题页</title>
        <script language="javascript" type="text/javascript">
        function msg()
        {
            alert(‘<%= getMsg("某某") %>’);
        }
       
        </script>
       
    </head>
    <body>
        <form id="form1" runat="server">
           <input type="button" onclick="msg()" value="你好" />
        </form>
    </body>
    </html>

     

    带变化的参数:
      <%@ Page Language="C#" AutoEventWireup="true" CodeFile="MergeDataTable.aspx.cs" Inherits="MergeDataTable" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>无标题页</title>
        <script language="javascript" type="text/javascript">
        function msg()
        {
            var msg=document.getElementById(‘txt’).value;
            alert(‘<%= getMsg("’+msg+’") %>’);
           
        }
       
        </script>
       
    </head>
    <body>
        <form id="form1" runat="server">

        请输入姓名:
        <input type="text" id="txt" />
        <input type="button" onclick="msg()" value="你好" />
        </form>
    </body>
    </html>
     

           经过修改,我的应用终于可以实现。虽然只是“” ‘’++这些符号的编写问题,但确实很需要讲究,顺序错了就的不到结果了。所以技术讲究细节,一点的错误可能导致功能无法调试成功,甚至一个大方法的修改。

    完整的成功的例子:

    CS页面:
      public string getInfo(string name)
            {
              
                string message ="fail";
                if(name!="")
                {
                    message = name+"你好笨!";
                   
                }
                return message;
            }
       
    ASPX页面:
    <%@ Page language="c#" Codebehind="TestHtml.aspx.cs" AutoEventWireup="false" Inherits="WebLearn.TestHtml" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    <HTML>
     <HEAD>
      <title>TestHtml</title>
      <meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
      <meta content="C#" name="CODE_LANGUAGE">
      <meta content="JavaScript" name="vs_defaultClientScript">
      <meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
     </HEAD>
     <body MS_POSITIONING="GridLayout">
      <form id="Form1" method="post" runat="server">
       <asp:textbox id="txtName" style="Z-INDEX: 102; LEFT: 48px; POSITION: absolute; TOP: 32px" runat="server"
        Height="34px" Width="176px"></asp:textbox><input id="submit" style="Z-INDEX: 101; LEFT: 248px; WIDTH: 64px; POSITION: absolute; TOP: 32px; HEIGHT: 32px"
        onclick="Say()" type="button" value="提交">
       <script language="javascript" type="text/javascript">
      function Say()
      {
           var name= document.getElementById("txtName").value;
           alert(‘<%= getInfo("’+name+’")%>’);
      }
       </script>
      </form>
     </body>
    </HTML>
    http://kenqukii.blog.hexun.com/25481799_d.html
            异步方法,我尝试过了两种,比较流行的一种目前还没有成功,一种成功了。没有成功的应用VS2005平台尝试,弄清楚究竟是什么原因。还有一种比较高深,找个时间好好研究它的原理,完成三种方法都能实现的心愿。