开发者

ASP.NET: connecting to a sql server database

(very newbie question, please help if you can)

how do i connect visual web developer to sql server express 2008? in the Database Explorer, i right click on Data Connections, click Add Connection..., and in the Data source box i choose Microsoft SQL Server (sqlClient), which i'm guessing doesn't connect me to a database file, but to sql server express itself(?). in the server name box when i click the drop down box, there's nothing there and that's where i get stuck.

can someone provide a link to how i can connect to sql server express; 开发者_如何学Pythonpreferably not an msdn link since i've been there and struggled with their walkthrough. thanks


usually you can type in .\SQLEXPRESS to connect to local SQL Server Express install...

the dot means the computer you are on, like localhost, and the \SQLEXPRESS is the SQL Server instance that the server is running on...this is the default instance name anyway for SQL Server Express...


Sql Server Express is a server class database engine. That means that, yes, you do connect to the server rather than read/write directly to a file. The server engine will then handle access to your data.

This is important. It's the mechanism that allows sql server to safely handle situations like asp.net web sites, where each page request runs in a different thread and you might have many that all want to write to your database at about the same time. If each process were just writing to the file, you'd have problems with data corruption. Sending requests to a single server process allows it to properly ensure each item runs in a separate, isolated transaction and handle those operations safely.

This mechanism is also important for performance. It allows the system to do things like pre-load tables and indexes into memory once, for use by any process that happens to make a request on that data. This is why a server engine like sql server express or even mysql will always be able to beat an in-process engine like sqlite in terms of performance as your data scales, even though sqlite is more less resource intensive initially and often seems faster on small data or small loads.

The need to have this server process running is also why you should not use sql server express for local desktop applications. In that situation, you don't want to force your users to have a server processes sitting there 24/7 using memory to cache index and table data you may only reference occasionally. This is where your sql server compacts, sqlites, and access databases come in.

As for your specific connection problem, there are a lot of things that could cause this. Are you sure sql server express is currently installed and running on your system? What happens if you just type "localhost" or "./SQLEXPRESS" in the box manually?


click on the Tools in Visual studio. choose Connect to Database. choose Data Source.. Microsoft Sql Server from the "choose Data Source" window. and then continue. new window will be open "Add Connection" type Microsoft SQL Server (SqlClient) in "Data source" and choose Server Name. Select your database name from the Select or enter a database name. and click on Test Connection.

in test connection window copy the connection string ... and you can use it in ur application'web.config. or on ur page

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜