ITPub博客

首页 > Linux操作系统 > Linux操作系统 > Visual studio 2003.net 开发Oracle 和Sql Server数据库的一些总结

Visual studio 2003.net 开发Oracle 和Sql Server数据库的一些总结

原创 Linux操作系统 作者:Kenniu 时间:2019-06-29 20:15:05 0 删除 编辑

用Visual studio 2003.net 开发Oracle 和Sql Server数据库是有一些区别的;比如开发oracle,你必须安装oracle client,配制好后,你才能开发;但Sql Server在client不需要安装任何东西,只要Sql Server数据库的配制及IP 就行;

一. 先介绍Visual Studio 2003.net开发Oracle(以ASP.NET为例)

1.1 你要配制好oracle;

1.2 开启Visual Studio 2003.net 去设定web.configure文件;

1.3 如何应用呢;

1.3.1 加DB Connection

Friend Class DBConnection
Private msConnectionString As String

Public Sub New(ByVal UID As String, ByVal PWD As String, ByVal DSN As String)
msConnectionString = "Provider=OraOLEDB.Oracle;User Id =" & UID & ";password=" & PWD & ";Data Source=" & DSN & ";DistribTX=0;"
End Sub
Public Sub New(ByVal DBType As String)
If DBType = "FA" Then
msConnectionString = "Provider=OraOLEDB.Oracle;Data Source=wzscashboxt;User Id =atest;password=atest;DistribTX=0;"
ElseIf DBType = "PCB" Then
msConnectionString = "Provider=OraOLEDB.Oracle;User Id =newacer;password=newacer;Data Source=wzscashpcbt;DistribTX=0;"
'Add new DSN
ElseIf DBType = "PROCESS" Then
msConnectionString = "Provider=OraOLEDB.Oracle;User Id =cms_user;password=cms_user;Data Source=PROCESS;DistribTX=0;"
End If
End Sub
Public Sub New()
msConnectionString = "User Id =atest;password=atest;Data Source=wzscashboxt"
End Sub

Friend Function getConnection() As OleDbConnection
Dim oConnection As New OleDbConnection(msConnectionString)
oConnection.Open()
Return oConnection
End Function
End Class

1.3.2

Dim oConn As OleDbConnection
Dim oDr As OleDbDataReader
Dim oCmd As OleDbCommand

sql = "select line from sta_conf where line='" &
oCmd.CommandText = sql
oDr = oCmd.ExecuteReader()
If Not oDr.HasRows Then
Return Nothing
Exit Function
End If
oDr.Close()
oDr = Nothing

二. 介绍Visual Studio 2003.net 开发Sql Server(以ASP.NET为例)

2.1 配制好Sql Server

2.2 开启Visual Studio 2003.net 去设定web.configure文件;


<!-- Add DB Connection for 上线的测试DB..-->

2.3 编程Sample

ConnString = CType(configurationAppSettings.GetValue("DatabaseConnUp", GetType(System.String)), String)
DBConnUp.ConnectionString = ConnString
DBConnUp.Open()

Dim oCMD As New SqlCommand
Dim oDr As SqlDataReader
Dim Sql As String

Try
If DBConnDown.State = ConnectionState.Closed Then
DBConnDown.Open()
End If

'Sql = "select count(*) Qisqty from MDPR_DataGather_Product where production_mode='" & xMo & " ' and record_time='" & Now.Date & "'"
Sql = "select count(*) Qisqty from MDPR_DataGather_Product where product_model='" & xMo & " '"
oCMD.CommandType = CommandType.Text
oCMD.CommandText = Sql
oCMD.Connection = DBConnDown
'oCMD = New SqlCommand(Sql, DBConnUp)
oDr = oCMD.ExecuteReader
If oDr.HasRows Then
oDr.Read()
Get_QIS_Down_Data = oDr("QISQty")
'iNQQty = oDr("NQQTY")
End If
oDr.Close()


来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/30193/viewspace-90031/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2002-11-29

  • 博文量
    143
  • 访问量
    108324