asp.net連接數(shù)據(jù)庫(kù) 增加,修改,刪除,查詢(xún)代碼
'數(shù)據(jù)庫(kù)連接
Public Sub connectionDB()
Try
serverUrl = readFromIni(My.Application.Info.DirectoryPath & "\config.dll", "Service Information", "IPAddress")
serverID = readFromIni(My.Application.Info.DirectoryPath & "\config.dll", "Service Information", "Password")
serverName = readFromIni(My.Application.Info.DirectoryPath & "\config.dll", "Service Information", "userID")
serverDataBase = readFromIni(My.Application.Info.DirectoryPath & "\config.dll", "Service Information", "DataBaseName")
If serverID <> "" Then
connectionSqlString = "server =" + serverUrl + ";Database=" + serverDataBase + ";uid =" + serverName + ";pwd=" + serverID + ";max pool size=500"
Else
connectionSqlString = "server =" & serverUrl & ";integrated security = SSPI ;database = " & serverDataBase & ""
End If
conSql = New SqlConnection(connectionSqlString)
objCommand.Connection = conSql
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
'數(shù)據(jù)操作執(zhí)行
Public Sub getConn(ByVal SqlStr As String, ByVal TableName As String)
Try
objCommand.CommandText = SqlStr
objDataSet.Clear()
objDataAdapter.SelectCommand = objCommand
objDataAdapter.Fill(objDataSet, TableName)
Catch ex As Exception
errNo = 1
MsgBox(ex.Message)
End Try
End Sub
'數(shù)據(jù)更新
Public Sub updateTable(ByVal StrSql As String)
objCommand.CommandText = StrSql
Try
conSql.Open()
Trans = conSql.BeginTransaction
objCommand.Transaction = Trans
objCommand.ExecuteNonQuery()
Trans.Commit()
Catch ese As Exception
MsgBox(ese.Message)
Trans.Rollback() '如果更新異常則取消所有更新
Finally
conSql.Close() '關(guān)閉連接
End Try
End Sub
- ASP.NET web.config中數(shù)據(jù)庫(kù)連接字符串connectionStrings節(jié)的配置方法
- asp.net連接查詢(xún)SQL數(shù)據(jù)庫(kù)并把結(jié)果顯示在網(wǎng)頁(yè)上(2種方法)
- ASP.NET 6種常用數(shù)據(jù)庫(kù)的連接方法
- ASP.NET2.0 SQL Server數(shù)據(jù)庫(kù)連接詳解
- ASP.NET連接數(shù)據(jù)庫(kù)并獲取數(shù)據(jù)方法總結(jié)
- ASP.NET連接MySql數(shù)據(jù)庫(kù)的2個(gè)方法及示例
- ASP.NET中操作SQL數(shù)據(jù)庫(kù)(連接字符串的配置及獲取)
- ASP.NET 連接ACCESS數(shù)據(jù)庫(kù)的簡(jiǎn)單方法
- ASP.NET連接 Access數(shù)據(jù)庫(kù)的幾種方法
- ASP.NET WebAPI連接數(shù)據(jù)庫(kù)的方法
相關(guān)文章
asp.net中實(shí)體類(lèi)對(duì)象賦值到表單的實(shí)現(xiàn)代碼
昨天在網(wǎng)上看到了一個(gè)利用反射表單賦值到實(shí)體類(lèi)對(duì)象的一個(gè)方法,自己就在加了個(gè)方法,從實(shí)體對(duì)象到表單,覺(jué)的很不錯(cuò)非常省事,所以把他寫(xiě)成了一個(gè)類(lèi),供以后使用2010-11-11Asp.net中Response.Charset與Response.ContentEncoding區(qū)別示例分析
這篇文章主要介紹了Asp.net中Response.Charset與Response.ContentEncoding區(qū)別示例分析,對(duì)于深入理解Asp.net程序設(shè)計(jì)有一定的幫助,需要的朋友可以參考下2014-08-08asp.net中一個(gè)linq分頁(yè)實(shí)現(xiàn)代碼
asp.net中一個(gè)linq分頁(yè)實(shí)現(xiàn)代碼,需要的朋友可以參考下。2011-12-12ASP.NET插件uploadify批量上傳文件完整使用教程
這篇文章主要為大家詳細(xì)介紹了ASP.NET插件uploadify批量上傳文件完整使用教程,感興趣的小伙伴們可以參考一下2016-07-07.NET的Ajax請(qǐng)求數(shù)據(jù)提交實(shí)例
這篇文章主要介紹了.NET的Ajax請(qǐng)求數(shù)據(jù)提交實(shí)例,較為詳細(xì)的分析了Ajax請(qǐng)求、數(shù)據(jù)的提交以及參數(shù)的傳遞技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-01-01ASP.NET實(shí)現(xiàn)License Key輸入功能的小例子
當(dāng)我們安裝微軟的軟件,多數(shù)軟件是需要輸入license key。它有五個(gè)文本框,輸入完第一個(gè)文本框之后,光標(biāo)自動(dòng)跳至下一個(gè)文本框。 Insus.NET今天也使用asp.net來(lái)模仿一個(gè)。呵呵。2013-03-03asp.net實(shí)現(xiàn)三層架構(gòu)的例子
這篇文章主要介紹了asp.net實(shí)現(xiàn)三層架構(gòu)的例子,十分的簡(jiǎn)單實(shí)用,有需要的小伙伴可以參考下。2015-07-07ASP.NET中防止頁(yè)面刷新造成表單重復(fù)提交執(zhí)行兩次操作
本文主要介紹在Session存儲(chǔ)唯一標(biāo)識(shí)Token,通過(guò)和后臺(tái)對(duì)比,以實(shí)現(xiàn)防止刷新提交表單的問(wèn)題。2016-04-04