I would like to convert my web pages from Asp classic to Asp.net (VB), What should I do instead of this code?
我想将我的网页从Asp classic转换为Asp.net(VB),我应该怎么做而不是这段代码?
conn.asp:
conn.asp的:
<%
Dim conn,connstr
connstr = "Provider=sqloledb; Data Source=.\SQLEXPRESS ;Initial Catalog=My_DB ;User Id=sa;Password=12345"
on error resume next
set conn=server.createobject("ADODB.CONNECTION")
conn.open connstr
if err then
err.clear
set conn=nothing
response.write "Connect Error!"
response.End
End IF
%>
Thank you for your time!
感谢您的时间!
1 个解决方案
#1
1
In C#
在C#中
using (SqlConnection connection = new SqlConnection("Provider=sqloledb; Data Source=.\SQLEXPRESS ;Initial Catalog=My_DB ;User Id=sa;Password=12345"))
{
connection.Open();
// Do work here; connection closed on following line.
}
VB.NET
VB.NET
Using connection As New SqlConnection("Provider=sqloledb; Data Source=.\SQLEXPRESS ;Initial Catalog=My_DB ;User Id=sa;Password=12345")
connection.Open()
// Do work here; connection closed on following line.
End Using
Various connection strings can be found here
这里可以找到各种连接字符串
#1
1
In C#
在C#中
using (SqlConnection connection = new SqlConnection("Provider=sqloledb; Data Source=.\SQLEXPRESS ;Initial Catalog=My_DB ;User Id=sa;Password=12345"))
{
connection.Open();
// Do work here; connection closed on following line.
}
VB.NET
VB.NET
Using connection As New SqlConnection("Provider=sqloledb; Data Source=.\SQLEXPRESS ;Initial Catalog=My_DB ;User Id=sa;Password=12345")
connection.Open()
// Do work here; connection closed on following line.
End Using
Various connection strings can be found here
这里可以找到各种连接字符串