asp.net 1.1 sql server 2000怎么实现
此软件服务器运行环境:asp.net1.1sqlserver2000,也就是说必须安装在“asp.net1.1sqlserver2000”服务器上才能使用。...
此软件服务器运行环境:asp.net 1.1 sql server 2000,也就是说必须安装在“asp.net 1.1 sql server 2000”服务器上才能使用。
展开
3个回答
展开全部
Imports System.Data.SqlClient
Public Class sqldb
Dim conn As New SqlConnection
Private strConn As String
Public Function checkconnection(ByVal str As String) As Boolean
Dim isFlag As Boolean = False
If conn.State = ConnectionState.Closed Then
conn.ConnectionString = str
conn.Open()
Return True
End If
Return False
End Function
Public Function checkconnection() As Boolean
Dim isFlag As Boolean = False
conn.ConnectionString = strConn
conn.Open()
If conn.State = ConnectionState.Open Then
isFlag = True : conn.Close()
End If
Return isFlag
End Function
Public Function returntable(ByVal sqlstr As String) As DataTable
Dim da As New SqlDataAdapter(sqlstr, conn)
Dim ds As New DataSet
conn.Close()
conn.ConnectionString = constr
If conn.State = ConnectionState.Closed Then
conn.Open()
End If
da.Fill(ds)
Return ds.Tables(0)
End Function
Public Sub inupde(ByVal sqlstr As String)
Dim com As New SqlCommand(sqlstr, conn)
com.ExecuteNonQuery()
End Sub
Public Function insertupdel(ByVal strUser As String, ByVal strPassword As String) As Boolean
Dim isFlag As Boolean = False
Dim StrNewSql As String = "Select txtuserid From users Where txtuserid='" & strUser & "'"
Dim strIntSql As String = "insert into users(txtuserid,txtpassword)Values('" & strUser & "','" & strPassword & "') "
Dim com As New SqlCommand
com.CommandText = StrNewSql
conn.ConnectionString = strConn
com.Connection = conn
If conn.State <> ConnectionState.Open Then conn.Open()
Dim dr As SqlDataReader = com.ExecuteReader() '这里是操作数据库,
If (Not dr.Read()) Then 'DR.Read()向前读数据库,如果数据库有数据,返回TRUE,说明不能添加了,就在前面加NOT,反之,如果数据库没有,返回FALSE,NOT FALSE=TRUE则执行IF下面的语句
dr.Close()
com.CommandText = strIntSql '这里是INSERT语句
com.ExecuteNonQuery() '这个向数据库添加数据,可以返回影响的条数
isFlag = True
End If
com.Dispose()
conn.Close()
Return isFlag
End Function
Public Sub New()
strConn = "user id =sa;password=;database=games;data source=."
End Sub
End Class
Public Class sqldb
Dim conn As New SqlConnection
Private strConn As String
Public Function checkconnection(ByVal str As String) As Boolean
Dim isFlag As Boolean = False
If conn.State = ConnectionState.Closed Then
conn.ConnectionString = str
conn.Open()
Return True
End If
Return False
End Function
Public Function checkconnection() As Boolean
Dim isFlag As Boolean = False
conn.ConnectionString = strConn
conn.Open()
If conn.State = ConnectionState.Open Then
isFlag = True : conn.Close()
End If
Return isFlag
End Function
Public Function returntable(ByVal sqlstr As String) As DataTable
Dim da As New SqlDataAdapter(sqlstr, conn)
Dim ds As New DataSet
conn.Close()
conn.ConnectionString = constr
If conn.State = ConnectionState.Closed Then
conn.Open()
End If
da.Fill(ds)
Return ds.Tables(0)
End Function
Public Sub inupde(ByVal sqlstr As String)
Dim com As New SqlCommand(sqlstr, conn)
com.ExecuteNonQuery()
End Sub
Public Function insertupdel(ByVal strUser As String, ByVal strPassword As String) As Boolean
Dim isFlag As Boolean = False
Dim StrNewSql As String = "Select txtuserid From users Where txtuserid='" & strUser & "'"
Dim strIntSql As String = "insert into users(txtuserid,txtpassword)Values('" & strUser & "','" & strPassword & "') "
Dim com As New SqlCommand
com.CommandText = StrNewSql
conn.ConnectionString = strConn
com.Connection = conn
If conn.State <> ConnectionState.Open Then conn.Open()
Dim dr As SqlDataReader = com.ExecuteReader() '这里是操作数据库,
If (Not dr.Read()) Then 'DR.Read()向前读数据库,如果数据库有数据,返回TRUE,说明不能添加了,就在前面加NOT,反之,如果数据库没有,返回FALSE,NOT FALSE=TRUE则执行IF下面的语句
dr.Close()
com.CommandText = strIntSql '这里是INSERT语句
com.ExecuteNonQuery() '这个向数据库添加数据,可以返回影响的条数
isFlag = True
End If
com.Dispose()
conn.Close()
Return isFlag
End Function
Public Sub New()
strConn = "user id =sa;password=;database=games;data source=."
End Sub
End Class
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Public Function insertupdel(ByVal strUser As String, ByVal strPassword As String) As Boolean
Dim isFlag As Boolean = False
Dim StrNewSql As String = "Select txtuserid From users Where txtuserid='" & strUser & "'"
Dim strIntSql As String = "insert into users(txtuserid,txtpassword)Values('" & strUser & "','" & strPassword & "') "
Dim com As New SqlCommand
com.CommandText = StrNewSql
conn.ConnectionString = strConn
com.Connection = conn
Dim isFlag As Boolean = False
Dim StrNewSql As String = "Select txtuserid From users Where txtuserid='" & strUser & "'"
Dim strIntSql As String = "insert into users(txtuserid,txtpassword)Values('" & strUser & "','" & strPassword & "') "
Dim com As New SqlCommand
com.CommandText = StrNewSql
conn.ConnectionString = strConn
com.Connection = conn
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
SQL2000,好古老啊
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询