易截截图软件、单文件、免安装、纯绿色、仅160KB

嵌入SQL语句

嵌入SQL语言:
我将一个sql链接到数据库,该数据库名为master(系统数据库)
then 给数据库添加新表,建立三个key:userid(int),name(char(10)),password(char(10))
在窗体中弄三个textbox控件,分别定义Name属性为userid,name,password;
再来一个button
以下是Form1.cs中的代码
 using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Data.OleDb;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Runtime.InteropServices;
using System.Configuration;
namespace Str
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void submit_Click(object sender, EventArgs e)
{
/*
* connect to Sql Server
* 方法一:写在这里
*/
//string strConnection = "Data Source=ZRQ-PC;";
//strConnection += "Initial Catalog=master;Integrated Security=True";
// SqlConnection objConnection = new SqlConnection(strConnection);
/*
* 方法二:
* 这个方法为工程添加了新建项“应用程序配置文件”
* 将上面的那段写在App.config里
*/
string strConnection = ConfigurationSettings.AppSettings["connectionstring"];
SqlConnection objConnection = new SqlConnection(strConnection);
/************************************************************************/
if (name.Text == "")
MessageBox.Show("请输入姓名!", "提示", 0);
else
{
objConnection.Open();
SqlCommand cmd = new SqlCommand("select * from judging where userid='" + userid.Text.Trim() + "'", objConnection);
/*
***********************************************************************************************


相关文档:

magento 在Magento中获取SQL语句

       Magento是在Zend Framework的基础上搭建而来,有两种方式可以从Magento的collection获得真正的SQL语句。
以 Mage::getResourceModel('reports/product_collection') 为例:
1
         $collection=Mage::getResourceModel('reports/product_collection'); ......

C#连接Access和SQL Server数据库

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Data.OleDb;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace Str
{
public partial class Form1 : F ......

magento 在Magento中使用自己写的SQL语句


Magento的Models
和Collection
 很强大,使用它们可以很方便的查询和操作数据库。但是有些场合,因为一些特殊需求或对Magento的了解不够深,可能会需要自己手写SQL语句来查询和操作数据库。以下分别是读写数据库的代码。

// For Read
// fetch read database connection that is used in Mage_Core modul ......

SQL Server 2008 定时作业的制定(SQL2005参考此方法)

--------------------------------------------------------------------------
--  Author : htl258(Tony)
--  Date   : 2010-04-29 19:07:45
--  Version:Microsoft SQL Server 2008 (RTM) - 10.0.1600.22 (Intel X86)
--          Jul  ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号