无法连接数据库 [英] cannot connect with database
本文介绍了无法连接数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用c#Express 2008版.我做了小程序.使用C#Express和sqlserver 2008 Express.但是,当我运行该程序的exe时,它无法与sqlserver连接.但是删除exe后,程序将从应用程序运行
调试文件夹中的文件.
正在关注是我的代码
I am using c# express edition 2008. I did small program using c# express and sqlserver 2008 express. But when I run exe of the program , it doesnot connect with sqlserver. But the program will run from the application after deleting exe
file from debug folder.
following is my code
private void button2_Click(object sender, EventArgs e)
{
try
{
planningrecord = SetValuesToMaterial();
WorkPlanning.InsertSchedule( planningrecord);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString(), "Job Planning... ", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
MessageBox.Show("Record Updated", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
private PlanningRecord SetValuesToMaterial()
{
try
{
MessageBox.Show(Application.ProductName);
// planningrecord.WorkName = textBox3.Text.Trim();
planningrecord.WorkDate = DateTime.Today;
planningrecord.DateFrom = dateTimePicker1.Value;
planningrecord.DateTo = dateTimePicker2.Value;
planningrecord.Module = "Academic";
planningrecord.Groupcode = cmbGroupCode.SelectedValue.ToString();
planningrecord.WhatWork = richTextBox1.Text.Trim();
planningrecord.HowDo = richTextBox2.Text.Trim();
planningrecord.Finished = false;
planningrecord.Priority = cmbStatus.SelectedItem.ToString();
planningrecord.Subgroup = cmbSubgroup.SelectedValue.ToString();
}
catch (Exception ex)
{
MessageBox.Show("Error occurred \nError message:" + ex.Message, Application.ProductName, MessageBoxButtons.OK,
MessageBoxIcon.Information);
}
Please can you advice how I can locate that folder to place config file database path. Following is the error message
'Object reference not set to an instance of an object.' Please help
推荐答案
连接数据库的代码在哪里?
Where is the code where you connect to the data base???
Noam B.
这篇关于无法连接数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文