• ¡Welcome to Square Theme!
  • This news are in header template.
  • Please ignore this message.
مهمان عزیز خوش‌آمدید. ورود عضــویت


امتیاز موضوع:
  • 9 رای - 2.67 میانگین
  • 1
  • 2
  • 3
  • 4
  • 5
Title: Connection String
حالت موضوعی
#1
 سلام
با این کد میخوام  برنامه به هر سروری  از بانک اتصال پیدا کنه اما اجرا نمیشه وکانکشن استرینگ  null برمیگردونه


کد:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Configuration;
using System.Data.SqlClient;
using System.Data;

namespace CS_WebConfig
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        DataTable dt;

        private void Form1_Load(object sender, EventArgs e)
        {
        }

        public string GetString()
        {
            return ConfigurationManager.AppSettings["ConnectionString"].ToString();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            SqlConnection con = new SqlConnection(GetString());
            SqlDataAdapter sqlda = new SqlDataAdapter("select * from TableInfo", con);
            dt = new DataTable();
            sqlda.Fill(dt);
            dataGridView1.DataSource = dt;
        }
    }
}

 
 
پاسخ
#2
کد:
public void CreateSqlConnection() { SqlConnection myConnection = new SqlConnection(); myConnection.ConnectionString = "Persist Security Info=False;Integrated Security=SSPI;database=northwind;server=mySQLServer;Connect Timeout=30"; myConnection.Open(); }

http://www.dreamincode.net/forums/topic/...appconfig/
گروه دور همی پارسی کدرز
https://t.me/joinchat/GxVRww3ykLynHFsdCvb7eg
 
پاسخ
  


موضوعات مشابه ...
موضوع نویسنده پاسخ بازدید آخرین ارسال
  Generate an MD5 hash of a given string Amin_Mansouri 0 2,660 06-14-2011، 07:05 AM
آخرین ارسال: Amin_Mansouri

پرش به انجمن:


Browsing: 1 مهمان