简体   繁体   English

如何使用asp.net连接到SQL Server

[英]How to connect to SQL Server with asp.net

I want to connect to SQL Server with ASP.NET. 我想使用ASP.NET连接到SQL Server。 Can any one give me some sample program to do so? 有人可以给我一些示例程序吗?

June R's example is inserting data. June R的示例是插入数据。

using System.Data;
using System.Data.SqlClient;

string Connection = "server=ALDAN; uid=sa; pwd=sa; database=GAZCAD; Connect Timeout=10000";

SqlConnection DataConnection = new SqlConnection(Connection);
// the string with T-SQL statement, pay attention: no semicolon at the end of //the statement
string Command = "Select * from myTable";
// create the SQLCommand instance
SQLCommand DataCommand = new SqlCommand(Command, DataConnection);
// open the connection with our database
DataCommand.Connection.Open();
// Data adapter
SqlDataAdapter da = new SqlDataAdapter(DataCommand);
// To fill data, i need a datatable.
DataTable dt = new DataTable();
// Filling my table
da.Fill(dt);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在ASP.NET中连接到SQL Server Compact 4.0? - How connect to SQL Server Compact 4.0 in ASP.NET? 如何连接到ASP.Net中不同域中的SQL Server? - How to connect to a SQL Server in a different domain in ASP.Net? ASP.Net如何连接到SQL Server表达 - How does ASP.Net connect to SQL Server express 如何连接sql和asp.net - how to connect sql and asp.net 如何将ASP.NET配置连接到SQL Server而不是SQL Server Express? - How to connect ASP.NET config to SQL Server instead of SQL Server Express? 使用Android连接到服务器上的asp.net sql服务器 - connect to asp.net sql server on server with android 如何从在容器中运行的 ASP.NET 核心应用程序连接到具有集成安全性的 Windows 服务器上的 SQL 服务器 - How to connect from ASP.NET Core application running in a container to SQL Server on Windows Server with Integrated Security 实施ASP.Net模拟/委派以从ASP.Net服务器连接到远程SQL Server无效 - Implementing ASP.Net impersonation/delegation to connect to remote SQL Server from ASP.Net server not working 从asp.net应用程序连接到SQL Server数据库 - connect to sql server database from asp.net application 将注册用户控件连接到ASP.NET中的SQL Server数据库 - Connect register user control to SQL Server database in ASP.NET
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM