使用C#直接存取SQL SERVER初學者手冊 |
|
conundrum
尊榮會員 發表:893 回覆:1272 積分:643 註冊:2004-01-06 發送簡訊給我 |
Beginners guide to accessing SQL Server through C# 使用C#直接存取SQL SERVER初學者手冊 Introduction In this article I plan to demonstrate how to insert and read data from a SQL Server or MSDE database. This code should work on both SQL Server , I am using 2000, and MSDE. I am using Visual Studio 2002, but this should work with Visual Studio 2003, Web Matrix, and the command line SDK. This code should work with both C# applications and C# web applications and webservices. This code does not compile on the FreeBSD with Rotor . 序言 在這份文章裡我計劃去證明如何去從 > >, CommandText = "INSERT INTO table (Column1, Column2) " >SqlConnection.Close() but remember to put it in try/catch because like SqlConnection.Open() it does not return errors but throws an exception instead. try { myConnection.Close(); } catch(Exception e) { Console.WriteLine(e.ToString()); } Loose Ends You now have the basics required to start using a SQL database in either webapplications or desktop applications. This article is by no means finished. I plan to expand the article and add a sample application as time allows. With information on stored procedures as well as an expanded connection options section. If you have any suggestions please leave them in the forum below |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |