| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 951 人关注过本帖
标题:数据库连接问题
只看楼主 加入收藏
jy02368430
Rank: 1
等 级:新手上路
帖 子:30
专家分:0
注 册:2007-1-11
收藏
 问题点数:0 回复次数:7 
数据库连接问题

大家连接数据库的时候是手动输入代码手动连接
还是用V studio里的连接,让他自动添加代码?
不过他自动连接时,我好象找不到他的连接代码在哪?
就好象连接MS SQL SERVER时,这句代码我就没在他里边找到过类似的
SqlConnection obc1=new SqlConnection("User ID=sa;Initial Catalog=wori;Data Source=127.0.0.1");

搜索更多相关主题的帖子: 数据库 SQL SERVER 代码 Catalog 
2007-03-28 22:35
叶子521
Rank: 1
等 级:新手上路
帖 子:19
专家分:0
注 册:2007-3-8
收藏
得分:0 
不过他自动连接时,我好象找不到他的连接代码在哪?

在自动生成的Design.cs里面,你找找看吧

2007-03-28 22:49
jy02368430
Rank: 1
等 级:新手上路
帖 子:30
专家分:0
注 册:2007-1-11
收藏
得分:0 

是这里吗?好象没有啊,还是我连接的方法不对?
mespace WindowsApplication1
{
partial class Form1
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;

/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}

#region Windows 窗体设计器生成的代码

/// <summary>
/// 设计器支持所需的方法 - 不要
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.woriDataSet = new WindowsApplication1.woriDataSet();
this.table1BindingSource = new System.Windows.Forms.BindingSource(this.components);
this.table1TableAdapter = new WindowsApplication1.woriDataSetTableAdapters.Table1TableAdapter();
this.textBox1 = new System.Windows.Forms.TextBox();
((System.ComponentModel.ISupportInitialize)(this.woriDataSet)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.table1BindingSource)).BeginInit();
this.SuspendLayout();
//
// woriDataSet
//
this.woriDataSet.DataSetName = "woriDataSet";
this.woriDataSet.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema;
//
// table1BindingSource
//
this.table1BindingSource.DataMember = "Table1";
this.table1BindingSource.DataSource = this.woriDataSet;
//
// table1TableAdapter
//
this.table1TableAdapter.ClearBeforeFill = true;
//
// textBox1
//
this.textBox1.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.woriDataSet, "Table1.name", true));
this.textBox1.Location = new System.Drawing.Point(12, 12);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(100, 21);
this.textBox1.TabIndex = 0;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(292, 272);
this.Controls.Add(this.textBox1);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
((System.ComponentModel.ISupportInitialize)(this.woriDataSet)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.table1BindingSource)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();

}

#endregion

private woriDataSet woriDataSet;
private System.Windows.Forms.BindingSource table1BindingSource;
private WindowsApplication1.woriDataSetTableAdapters.Table1TableAdapter table1TableAdapter;
private System.Windows.Forms.TextBox textBox1;
}
}

2007-03-28 23:01
jy02368430
Rank: 1
等 级:新手上路
帖 子:30
专家分:0
注 册:2007-1-11
收藏
得分:0 

怎么连个热心人都没有?

大家连接数据库的时候是手动输入代码手动连接
还是用V studio里的连接,让他自动添加代码?

2007-03-29 14:30
lisir888
Rank: 1
等 级:新手上路
帖 子:259
专家分:0
注 册:2006-8-23
收藏
得分:0 

用代码连。这样好控制

2007-03-29 15:02
bygg
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:乖乖的心中
等 级:版主
威 望:241
帖 子:13555
专家分:3076
注 册:2006-10-23
收藏
得分:0 
你可以单独做个数据库连接的东西.这样方便服务器变动的更改和修正..

飘过~~
2007-03-29 16:48
zja0440
Rank: 1
等 级:新手上路
帖 子:39
专家分:0
注 册:2007-3-19
收藏
得分:0 

代码自己写撒!2种登陆方式:
1,数据库连接命令
private string ss="Data Source=.;Integrated Security=SSPI;Initial Catalog=Employee";
private string ss="server=.;uid=sa;pwd=;database=Employee";

2,combox显示和实际处理的列方法
combox.DisplayMember=" " 显示的列
combox.valuesMember=" "实际处理的列
插入combox值,需要用到的是this.combox.SelectedValue.tostring();属性

3,数据插入combox第1列
把数据插入listview第1列,如果不写,数据将插入第2列
listview.SubItems[0].Text=值所在的位置.tostring();

4,显示当前日期+时间
TimePanel.Text="当前日期:"+DateTime.Now.ToLongDateString()+" "+"当前时间:"+DateTime.Now.ToLongTimeString();
显示:当前日期:2007-1-1 当前时间:10:00:11

5,调用XP下的计算器
Help.ShowHelp(this,"C:\\WINDOWS\\system32\\calc.exe");

上面是我学习笔记,很久没更新了!


2007-03-29 22:03
Doubleling
Rank: 1
等 级:新手上路
帖 子:43
专家分:0
注 册:2007-3-31
收藏
得分:0 
为什么我每次手写代码时都会出错呢,真烦恼!

2007-03-31 23:13
快速回复:数据库连接问题
数据加载中...
 
   



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

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