MSSQL数据库使用ASP.NET连接调用样例
详细解答可以参考官方帮助文档 以下是我们用C#来实现的,见下列实例代码,请万网独立服务器客户参考: !--%@-- ‘ 声明C# public DataSet dsCustomer;protected void Page_Load(Object Src, EventArgs E ) { ‘ 在打开页面时连接数据库 SQLConnection myConnection = new SQLConnection('server=127.0.0.1;uid=xxx;pwd=*;database=**_db'); SQLDataSetCommand CustomersDSCommand = new SQLDataSetCommand('select from customers', myConnection); dsCustomer = new DataSet(); CustomersDSCommand.FillDataSet(dsCustomer,'Customers');foreach (DataRow Customer in dsCustomer.Tables['Customers'].Rows){Response.Write(Customer['CustomerId'].ToString() + ' ' ); } } 注:云虚拟主机和轻云服务器,数据库和WEB是分离机制,请在页面程序代码调用数据库时,不要使用local或者127.0.0.1等本机调用,使用万网提供的数据库地址,MSSQL地址dsc-序号.hichina.com,具体序号,需要您登录万网会员区后,进入我的主机>管理>查看主机的相关信息。如问题还未解决,请联系售后技术支持。
赞0
踩1