在修改后重新赋值
private void button1_Click(object sender, EventArgs e)
{
uname = textBox1.Text.Trim();
pword = textBox2.Text.Trim();
server = comboBox1.Text.Trim();
DataBase.strConn = "Data Source= " + Form4.server + ";User ID=" + Form4.uname + ";Password=" + Form4.pword + "";
*****************************************************************************
签名档: http://feiyun0112.cnblogs.com/
private void button1_Click(object sender, EventArgs e)
{
uname = textBox1.Text.Trim();
pword = textBox2.Text.Trim();
server = comboBox1.Text.Trim();
DataBase.strConn = "Data Source= " + Form4.server + ";User ID=" + Form4.uname + ";Password=" + Form4.pword + "";
*****************************************************************************
签名档: http://feiyun0112.cnblogs.com/
解决方案 »
- C#,MySql的连接方法
- 标题,标题怎么写...关于POST方法得到网页,服务器错误...
- C#裏,XML問題,,請高手賜教...江湖急救。。。
- 升级到vs2008 后单元测试不能通过
- SocketException 在其上下文中,该请求地址无效
- 开发完成的管理系统和输入法切换的冲突问题?
- 关于jmail ,为什么会弹出“the message war undeliverable,all servers failed to receive the message"
- 新手求助、怎样把视频文件导入到自已的c#项目中???求大神指导!!!非常感谢!!!
- 如何在邮件程序中发送中文
- c#访问数据库
- WPF窗体问题 高手请进
- 在.net网页打开winform程序
public static string uname;
public static string pword;
public static string server;
肯定没有值
此时如果实例化DataBase类肯定无法获取值
看你的Form4与DataBase的实例化顺序
public static string uname;
public static string pword;
public static string server;
的值
此时Form4肯定没有实例化
所以无法取值
class DataBase(Form f)//类构造函数
{
static string strConn = "Data Source= " + Form4.server +......//加断点,方便待会看到对应的值
}
Form中的button事件 uname = textBox1.Text.Trim();
pword = textBox2.Text.Trim();
server = comboBox1.Text.Trim();
DataBase _dataBase=new DataBase(this);//添加这行代码
.......
这个错误意思是它没有被声明为public
{
uname = textBox1.Text.Trim();
pword = textBox2.Text.Trim();
server = comboBox1.Text.Trim();
//////////////3个变量在这里获取了相应值,在后面就可以从变量取值了
OracleConnection conn = new OracleConnection();
conn.ConnectionString = "Data Source= " + Form4.server + ";User ID=" + Form4.uname + ";Password=" + Form4.pword + "";
conn.Open();
public class DataBase(Form f)//类构造函数在这里添加public
{
static string strConn = "Data Source= " + Form4.server +......//加断点,方便待会看到对应的值
}