如何使用C#应用程序创建集成数据库? [英] How Do I Create Intergrated Database With C# Application?

查看:82
本文介绍了如何使用C#应用程序创建集成数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace EnQApp
{
    public partial class LoGEnq : Form
    {
        public LoGEnq()
        {
            InitializeComponent();
        }

        private void Btn1_Click(object sender, EventArgs e)
        {
            String Usrname = UName.Text;
            SqlConnection cn = new SqlConnection(global::DataBaseTest.Propeties.Settings.Default.Database1ConnectionString);

            try {
                cn.Open();
                SqlCommand cmd = new SqlCommand();
                cmd.CommandText = "SELECT * FROM Login WHERE Uname=@Usr;";
                cmd.Parameters.AddWithValue("@Usr",Usrname);

                cmd.ExecuteNonQuery();
                MessageBox.Show("Thank you");
            }
            catch (Exception ex) { }
            finally { }
        }





会出现这个错误吗?

类型或命名空间名称'DataBaseTest '无法在全局命名空间中找到(您是否缺少程序集引用?)



我可以做些什么来解决这个问题?



It will come this error?
The type or namespace name 'DataBaseTest' could not be found in the global namespace (are you missing an assembly reference?)

What i can do for solve this issue?

推荐答案

错误意味着它不知道DataBaseTest是什么。因此,您可能需要添加对DataBaseTest代码所在位置的引用或包含类,以便编译器可以找到它。
The error means it does not know what DataBaseTest is. So, you may need to add a reference to wherever the code for DataBaseTest is or include the classes so the compiler can find it.


而不是SqlConnection(global :: DataBaseTest.Propeties.Settings) .Default.Database1ConnectionString);



将其更改为



SqlConnection(global :: EnQApp.Propeties。 Settings.Default.Database1ConnectionString);



它会起作用
Instead of SqlConnection(global::DataBaseTest.Propeties.Settings.Default.Database1ConnectionString);

change it to

SqlConnection(global::EnQApp.Propeties.Settings.Default.Database1ConnectionString);

It will work


这篇关于如何使用C#应用程序创建集成数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆