Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
A

Alaric Dailey

@Alaric Dailey
About
Posts
5
Topics
0
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • SQL Server Express doesn't work
    A Alaric Dailey

    There are lots of settings in the connectionstring for SQL server, I would visit connectionstrings.com or msdn.microsoft.com to get all the details. But GENERALLY you needs just a handful of settings. Data Source - this is your server, and instance name, localhost, . , and (local) are all aliases to your local machine. If you are using anything other than the default instance, like SQLExpress, you need to add it after the servername, with a backslash. User Instance - this is required if you are using SQLExpress and changes how the database is mounted. AttachDbFilename - is the database file you wish to attach. Initial Catalog - the name of the database you want to connect to. So your new connection string, assuming a database name of "cars" on a default instance on your local server using integrated security (so you don't have to store usernames and passwords). It would look like this

    Data Source=(local);Initial Catalog=cars; Integrated Security=SSPI;

    Notice the AttachDbFilename and User Instance parameters have been removed.

    ASP.NET database sql-server design sysadmin data-structures

  • SQL Server Express doesn't work
    A Alaric Dailey

    If you are using the the App_Data directory under a Web application then you should be using the |DataDirectory| functionality. Then you don't need to do the Server.MapPath yourself. On first glance it looks like your SQLEXPRESS instance doesn't have permission to the data directory, the directory doesn't exist, or the file doesn't exist. But upon closer inspection, you want to remove the setting "User Instance=false" that is going to try to mount the database differently than what you are trying to accomplish. For more information read this. That being said, having your web app be able to create files, even database files in your sites directories, or even anywhere other than the temp directory is a huge security risk. Consequently, your "CREATE DATABASE" looks to be expected behavior. One final note: ASP.NET defines a connectionstring called "LocalSqlServer" in the machine.config, thus it is inherited by all asp.net websites, the default concection string is

    data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true

    which is nearly identical to your connection string (once the user instance bit is corrected), and the structure of that particular database provides support for all the normal user, password, and permission templates that .NET provides.

    ASP.NET database sql-server design sysadmin data-structures

  • Managing Multiple SSL Certificates in a web API
    A Alaric Dailey

    This sounds suspiciously like an issue for your webserver, not an application. Because it sounds like you are trying to use 1 certificate for multiple websites, hosted on a single IP. If this is indeed what you are trying to do, it doesn't really have anything to do with .NET, instead it has to do with your hosting software. IIS does support this, Apache (last I checked) will not. Is this indeed what you are trying to do?

    WCF and WF csharp wcf php com sysadmin

  • MultiThread and File process
    A Alaric Dailey

    This is a serialport example, since you keep mentioning COM PORTS I am supposing this is what you are looking for. I will be happy to help out more, but if this still isn't what you need, a better description of what you need in is order.

    using System;
    using System.IO.Ports;
    using System.Threading;
    using System.Windows.Forms;

    namespace MultiThreadedFileRead
    {
    public partial class Form1 : Form
    {
    private readonly object _syncRoot = new object();

        public Form1()
        {
            InitializeComponent();
        }
    
    
        private void Form1\_Load(object sender, EventArgs e)
        {
            serialPort1.DataReceived += SerialPort1DataReceived;
            serialPort2.DataReceived += SerialPort2DataReceived;
            serialPort3.DataReceived += SerialPort3DataReceived;
        }
    
        private void SerialPort1DataReceived(object sender, SerialDataReceivedEventArgs e)
        {
            ThreadPool.QueueUserWorkItem(ThreadFunc, sender);
        }
    
        private void SerialPort2DataReceived(object sender, SerialDataReceivedEventArgs e)
        {
            ThreadPool.QueueUserWorkItem(ThreadFunc, sender);
        }
    
        private void SerialPort3DataReceived(object sender, SerialDataReceivedEventArgs e)
        {
            ThreadPool.QueueUserWorkItem(ThreadFunc, sender);
        }
    
        private void ThreadFunc(object state)
        {
            SerialPort port = state as SerialPort;
            if (port != null)
            {
                try
                {
                    //do processing here.
                    
                }
                catch (Exception)
                {
                    //don't let the thread throw directly
                }
            }
        }
    }
    

    }

    C# help tutorial question

  • MultiThread and File process
    A Alaric Dailey

    Is something like this what you are looking for? (this example will allow you to read as many files as you like)

    using System;
    using System.IO;
    using System.Threading;
    using System.Windows.Forms;

    namespace MultiThreadedFileRead
    {
    public partial class Form1 : Form
    {
    private readonly object _syncRoot = new object();

        public Form1()
        {
            InitializeComponent();
        }
    
        private void button1\_Click(object sender, EventArgs e)
        {
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                listBox1.Items.Add(openFileDialog1.FileName);
            }
        }
    
        private void button2\_Click(object sender, EventArgs e)
        {
            foreach (object file in listBox1.Items)
            {
                ThreadPool.QueueUserWorkItem(ThreadFunc, file);
            }
        }
    
    
        private void WouldBeEventHandler(string s)
        {
            if (InvokeRequired)
            {
                Action<string> d = WouldBeEventHandler;
                BeginInvoke(d, new object\[\]{s});
                return;
            }
    
            lock (\_syncRoot)
            {
                listBox2.Items.Add(s);
            }
        }
    
        private void ThreadFunc(object state)
        {
            string filename = state as string;
            if (!string.IsNullOrEmpty(filename))
            {
                using (StreamReader fs = File.OpenText(filename))
                {
                    while (!fs.EndOfStream)
                    {
                        WouldBeEventHandler(fs.ReadLine());
                        Application.DoEvents();
                    }
                }
            }
        }
    }
    

    }

    C# help tutorial question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups