connect.cs

(开头部分) 4KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

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

namespace dbToCode
{
    public partial class connect : Form
    {
        public connect()
        {
            InitializeComponent();
        }

        public static string connstr = "";
        public static IList<string> mylist = new List<string>();
        public static IList<string> mylistP = new List<string>();
        public static IList<string> mylistV = new List<string>();//绑定视图
        public static string dataBaseName = "";//数据库名称
        public static CodeSaveOption option;
        private void btnConnect_Click(object sender, EventArgs e)//连接
        {
            option = CodeSaveOption.FileToObj(new CodeSaveOption());
            if (option == null)
            {
                option = new CodeSaveOption();
               
            }
            option.PassWrod = txtPwd.Text.Trim();
            option.ServerPath = txtServerName.Text.Trim();
            option.UserID = txtUsername.Text.Trim();
            option.DataBase = cmbDataBaseName.Text;
            CodeSaveOption.Serial(option);

            if (cmbDataBaseName.Text == "")
            {
                MessageBox.Show("请选择数据库!");
                return;
            }
            connstr = "Data Source=" + txtServerName.Text.Trim() + ";Initial Catalog=" + cmbDataBaseName.Text + ";Persist Security Info=True;User ID=" + txtUsername.Text.Trim() + ";Password=" + txtPwd.Text + "";
            SqlConnection oleConn = new SqlConnection(connstr);

            string sql = "SELECT   name   FROM   sysobjects   WHERE   xtype   =   'U'   AND   name   <>   'dtproperties' order by name";

            sql +=   "  use "+cmbDataBaseName.Text+" select  a.name from  sysobjects  a where  a.xtype='P'  and  a.status>=0 order  by  a.name ";
            sql += " use " + cmbDataBaseName.Text + " select name from sysobjects where type='V'";
            SqlCommand oleCmd = new SqlCommand(sql, oleConn);
            try
            {
                oleCmd.Connection.Open();
            }
            catch
            {
                MessageBox.Show("数据库连接失败!");
                return;
            }
后面还有 83 行代码,购买后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。