如果您所使用的 SQL Server 数据库连不上,可以通过这个方法进行测试数据库连接。
温馨提示:
- .本方法只适用于测试SqlServer数据库连接,请核对您输入的是SqlServer的数据库信息。本文档不适用于MySql数据库。
- 如何查看数据库信息
测试连接方法:
1.打开记事本,不要写任何字,然后保存为 dsds.udl (即为重命名)到桌面。
2.双击刚刚保存的文件。
3.输入数据库的地址,数据库账号,密码,数据库名称。
4.单击“测试连接”,提示连接成功。
所有的鸟儿他们都知道, 他们的巢应该筑在什么地方, 鸟儿知道自己该在什么地方筑巢, 那就意味着他们了解他们自己的使命。 我们身为万物之灵的人类, 怎么会不知道,连鸟儿都知道的道理呢?
如果您所使用的 SQL Server 数据库连不上,可以通过这个方法进行测试数据库连接。
1.打开记事本,不要写任何字,然后保存为 dsds.udl (即为重命名)到桌面。
2.双击刚刚保存的文件。
3.输入数据库的地址,数据库账号,密码,数据库名称。
4.单击“测试连接”,提示连接成功。
winform 程序配合 sqlite 来存储数据,推荐sourceforge.net/projects/sqlitebrowser/ 来配合开发过程。
首先感谢下sqlite作者们 谨记他们的blessing
先安装依赖项
yum install bison gettext glib2 freetype fontconfig libpng libpng-devel libX11 libX11-devel glib2-devel libgdi* libexif glibc-devel urw-fonts java unzip gcc gcc-c++ automake autoconf libtool make bzip2 wget
cd /usr/local/src
wget http://download.mono-project.com/sources/mono/mono-3.0.2.tar.bz2
tar jxf mono-3.0.2.tar.bz2
cd mono-3.0.2
./configure –prefix=/usr/local
make && make install
如果在小内存的机器上运行,可以允许使用高虚拟内存。
SqlMetal 命令行工具可为 .NET Framework 的 LINQ to SQL 组件生成代码和映射。通过应用本主题后面出现的选项,可以指示 SqlMetal 执行若干种不同的操作,其中包括:
从数据库生成源代码和映射属性或映射文件。
从数据库生成供自定义使用的中间数据库标记语言 (.dbml) 文件。
从 .dbml 文件生成代码和映射属性或映射文件。
默认情况下, SQLMetal 文件位于 drive:\Program Files\Microsoft SDKs\Windows\vn.nn\bin 下。
http://blog.miniasp.com/post/2008/08/20/Using-SqlMetalexe-to-create-LINQ-to-SQL-DBML.aspx
直接輸入 sqlmetal 指令不加上任何參數就會列出完整的說明:
Microsoft (R) Database Mapping Generator 2008 version 1.00.30729 for Microsoft (R) .NET Framework version 3.5 Copyright (C) Microsoft Corporation. All rights reserved. SqlMetal [options] [<input file>] Generates code and mapping for the LINQ to SQL component of the .NET framework. SqlMetal can: - Generate source code and mapping attributes or a mapping file from a database. - Generate an intermediate dbml file for customization from the database. - Generate code and mapping attributes or mapping file from a dbml file. Options: /server:<name> Database server name. /database:<name> Database catalog on server. /user:<name> Login user ID (default: use Windows Authentication). /password:<password> Login password (default: use Windows Authentication). /conn:<connection string> Database connection string. Cannot be used with /server, /database, /user or /password options. /timeout:<seconds> Timeout value to use when SqlMetal accesses the database (default: 0 which means infinite). /views Extract database views. /functions Extract database functions. /sprocs Extract stored procedures. /dbml[:file] Output as dbml. Cannot be used with /map option. /code[:file] Output as source code. Cannot be used with /dbml option. /map[:file] Generate mapping file, not attributes. Cannot be used with /dbml option. /language:<language> Language for source code: VB or C# (default: derived from extension on code file name). /namespace:<name> Namespace of generated code (default: no namespace). /context:<type> Name of data context class (default: derived from database name). /entitybase:<type> Base class of entity classes in the generated code(default: entities have no base class). /pluralize Automatically pluralize or singularize class and member names using English language rules. /serialization:<option> Generate serializable classes: None or Unidirectional (default: None). /provider:<type> Provider type: SQLCompact, SQL2000, SQL2005, or SQL2008. (default: provider is determined at run time). <input file> May be a SqlExpress mdf file, a SqlCE sdf file, ora dbml intermediate file. Create code from SqlServer: SqlMetal /server:myserver /database:northwind /code:nwind.cs /namespace:nwind Generate intermediate dbml file from SqlServer: SqlMetal /server:myserver /database:no rthwind /dbml:northwind.dbml /namespace:nwind Generate code with external mapping from dbml: SqlMetal /code:nwind.cs /map:nwind.map northwind.dbml Generate dbml from a SqlCE sdf file: SqlMetal /dbml:northwind.dbml northwind.sdf Generate dbml from SqlExpress local server: SqlMetal /server:.\sqlexpress /database:northwind /dbml:northwind.dbml Generate dbml by using a connection string in the command line: SqlMetal /conn:"server='myserver'; database='northwind'" /dbml:northwind.dbml
调用 NewRow 时,将使用现有的表架构向表中添加一行,并为该行填充默认值,同时将 DataRowState 设置为 Added。 调用 ImportRow 将保留现有的 DataRowState 以及该行中的其他值。如果作为参数传递的 DataRow 处于分离状态,则忽略它,并且不引发异常。 新行将添加到数据表的末尾。
如果新行违反了约束,则不会把它添加到数据表。
可通过 DataTable.Rows.Find 和 DataTable.Rows.IndexOf 获取新行的索引。 有关更多信息,请参见DataRowCollection和Rows。
GridVIew 的行选择事件处理代码是:
CustomersGridView_SelectedIndexChanging(Object sender, GridViewSelectEventArgs e)
如果我们构造需要的参数 GridViewSelectEventArgs (在本GridView的 行绑定事件里面,根据外部条件来得到e.Row.RowIndex)
public GridViewSelectEventArgs (
int newSelectedIndex )
然后调用:CustomersGridView_SelectedIndexChanging(Object sender, GridViewSelectEventArgs e)
1 :普通SQL语句可以用Exec执行
eg: Select * from tableName
Exec(‘select * from tableName’)
Exec sp_executesql N’select * from tableName’ — 请注意字符串前一定要加N
2:字段名,表名,数据库名之类作为变量时,必须用动态SQL
eg:
declare @fname varchar(20)
set @fname = ‘FiledName’
Select @fname from tableName — 错误,不会提示错误,但结果为固定值FiledName,并非所要。
Exec(‘select ‘ + @fname + ‘ from tableName’) — 请注意 加号前后的 单引号的边上加空格
当然将字符串改成变量的形式也可
declare @fname varchar(20)
set @fname = ‘FiledName’ –设置字段名
declare @s varchar(1000)
set @s = ‘select ‘ + @fname + ‘ from tableName’
Exec(@s) — 成功
exec sp_executesql @s — 此句会报错
declare @s Nvarchar(1000) — 注意此处改为nvarchar(1000)
set @s = ‘select ‘ + @fname + ‘ from tableName’
Exec(@s) — 成功
exec sp_executesql @s — 此句正确
3. 输出参数
declare @num int,
@sqls nvarchar(4000)
set @sqls=’select count(*) from tableName’
exec(@sqls)
–如何将exec执行结果放入变量中?
declare @num int,
@sqls nvarchar(4000)
set @sqls=’select @a=count(*) from tableName ‘
exec sp_executesql @sqls,N’@a int output’,@num output
select @num
出错信息的例子:
下面这些出错信息,是你遇上这些编译问题时,你也许看到的运行时异常类型的例子:
Unable to cast object of type ‘ASP.masterpage_master’ to type ‘ASP.masterpage_master’.
(无法将ASP.masterpage_master类型的对象转换成ASP.masterpage_master类型)
或者:
Could not load file or assembly ‘App_Web_e9dbmaj, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null’ or one of its dependencies. The system cannot find the file specified.
(无法装载文件或程序集“App_Web_e9dbmaj, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null”或它的依赖向。系统找不到指定的文件。)
或者:
Compiler Error Message: CS0006: Metadata file ‘C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\cms.web\44e73607\b028acb3\App_global.asax.fakktchx.dll’ could not be found
(编译错误信息:CS0006:找不到元数据文件“C:\WINDOWS\Microsoft.NET\Framework\v2.0. 50727\Temporary ASP.NET Files\cms.web\44e73607\b028acb3\App_global.asax.fakktchx. dll”。)
或者:
System.InvalidOperationException: The resource class for this page was not found. Please check if the resource file exists and try again
(System.InvalidOperationException: 找不到当前页面的资源类。请检查资源文件确实存在,然后再试。)
这些问题的临时解决方案:
如果你有一个应用开始抛出上面这些错误中的某一个时,你通常可以马上施用一个临时解决方案,打开你应用的web.config文件,将 <compilation> 节的 batch 属性设置成false:
<configuration>
<system.web>
<compilation debug="false" batch="false"></compilation>
</system.web>
</configuration>
这告诉ASP.NET把单个的 .aspx/.ascx 文件动态编译成单独的程序集,这会避免触发异常的循环引用的问题。
你也可以使用下列步骤,删去“Temporary ASP.NET Files”缓存里的文件,来临时解决这个问题:
点击Windows开始按钮,点击运行,输入 iisreset /stop,然后点击OK。
打开 驱动字母: WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files 目录。
删除第二步里你找出的目录里的所有文件和所有文件夹。
点击开始,点击运行,输入 iisreset /start,然后点击OK。
如果使用asp.net 里面的TreeView。在选中某个节点会发后,当前选中节点,如果太深了,会无法回复到初始的TreeView的折叠样子。
通过修改TreeView..::.PopulateNodesFromClient可以改变这个特性。