1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
| '---------------------------------------------
'数据库链接DLL www.yemaosheng.com
'---------------------------------------------
Imports System.Data
Imports System.Data.OleDb
Public Class Conn
Dim myConnection As OleDbConnection
Dim myCommand As OleDbCommand
Dim myDataadapter As SqlDataAdapter
Dim myDatareader As OleDbDataReader
Dim myDataset As DataSet
'连接数据库
Public Function Conection(ByVal strConn)
myConnection = New OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA Source=" & strConn)
myConnection.Open()
End Function
'执行Select将结果放入DataSet并返回
Public Function ExecuteToDataAdapter(ByVal strSql, ByVal tb) As DataSet
myCommand = New SqlCommand(strSql, myConnection)
myDataadapter = New SqlDataAdapter(myCommand)
myDataset = New DataSet
myDataadapter.Fill(myDataset, tb)
Return myDataset
End Function
'执行Select语句
Public Function ExecuteQuery(ByVal strSql) As OleDbDataReader
myCommand = New OleDbCommand(strSql, myConnection)
myDatareader = myCommand.ExecuteReader()
Return myDatareader
End Function
'执行Update和Insert语句
Public Function ExecuteUpdate(ByVal strSql)
myCommand = New OleDbCommand(strSql, myConnection)
myCommand.ExecuteNonQuery()
End Function
'关闭数据库连接
Public Function Close()
myDatareader.Close()
myConnection.Close()
myConnection.Dispose()
End Function
'判断数据库中的字段是否为空
Public Function DbLen(ByVal Field As Object) As Integer
Dim len As Integer
Dim NewVar As String = ""
Dim ObjType As Type = Field.GetType()
If ObjType.FullName = "System.DBNull" Then
NewVar = Field.Value.ToString
Else
NewVar = Field
End If
Return NewVar.Length
End Function
End Class
'---------------------------------------------
'aspx调用 www.yemaosheng.com
'---------------------------------------------
<%@ Page Language="VB" Debug="true" %>
<%@ Import Namespace="DBConn" %>
<%@ Import Namespace="System.Data.OleDb" %>
<%@ Import Namespace="System.Data" %>
<%
Dim conn As New Conn()
Dim dtr As OleDbDataReader
Dim sql As String
conn.Conection(Request.ServerVariables("APPL_PHYSICAL_PATH") & "common\survey.mdb")
If request.Form("radio_survey")<>"" Then
sql="UPDATE tb_surveyitem SET surveyitem_item" & request.Form("radio_survey") & "=surveyitem_item" & request.Form("radio_survey") & "+1 WHERE surveyitem_survey=" & request.Form("hidden_surveyid")
conn.ExecuteUpdate(sql)
End If
dtr=conn.ExecuteQuery("select * from tb_survey,tb_surveyitem where survey_id=surveyitem_survey and survey_id=" & request.Form("hidden_surveyid"))
dtr.Read()
%>
<table width="500" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#333333">
<tr>
<td><table width="500" border="0" cellspacing="1" cellpadding"0">
<tr align="center">
<td colspan="2" bgcolor="#006699" class="title_text1"><strong><%=dtr("survey_title")%></strong></td>
</tr>
<%
Dim I As Integer
For I = 1 To 6
If conn.DbLen(dtr("survey_item" & I & "title")) > 0 then
%>
<tr>
<td width="100" bgcolor="#006699" class="title_text1"><%=dtr("survey_item" & I & "title")%></td>
<td width="400" bgcolor="#ECF9FF" valign=middle>
<img src='images/left-line.gif' width='<%=dtr("surveyitem_item" & I)*10%>' height=10>
</td>
</tr>
<%
End If
Next
%>
</table></td>
</tr>
</table>
<%
dtr.Close()
conn.Close()
%>
'---------------------------------------------
<TABLE cellSpacing=2 cellPadding=2 width=600 bgColor=#ffffff>
<TBODY>
<TR class="content_text1">
<TD bgColor=#bfd5e3 colSpan=6>招聘信息</TD>
</TR>
<%
Dim conn As New Conn()
Dim dtr As OleDbDataReader
conn.Conection(Request.ServerVariables("APPL_PHYSICAL_PATH") & "common\hr.mdb")
dtr=conn.ExecuteQuery("select * from tb_hr where hr_state=1")
While dtr.Read()
%>
<TR class="content_text1">
<TD width=10% bgColor=#e9e9e9>职位名称:</TD>
<TD width=50%><%=dtr("hr_job")%></TD>
<TD width=10% bgcolor="#E9E9E9">性别要求:</TD>
<TD width=10%><%=dtr("hr_gender")%></TD>
<TD width=10% bgcolor="#E9E9E9">招聘人数:</TD>
<TD width=10%><%=dtr("hr_num")%></TD>
</TR>
<TR class="content_text1">
<TD width=10% valign="top" bgColor=#e9e9e9>职位描述:</TD>
<TD colspan="5"><%=Replace(dtr("hr_desc"),vbCrLf,"<br>")%></TD>
</TR>
<TR class="content_text1">
<TD bgColor=#bfd5e3 colspan="6"> </TD>
</TR>
<%
End While
dtr.Close()
conn.Close()
%>
</TBODY>
</TABLE>
'---------------------------------------------
Dim conn As New Conn()
Dim ds As DataSet
Dim dr As DataRow
ds = conn.ExecuteToDataAdapter("select * from tb_board","board")
For Each dr In ds.Tables("board").Rows
response.write(dr("board_id"))
Next |
'---------------------------------------------
'数据库链接DLL www.yemaosheng.com
'---------------------------------------------
Imports System.Data
Imports System.Data.OleDb
Public Class Conn
Dim myConnection As OleDbConnection
Dim myCommand As OleDbCommand
Dim myDataadapter As SqlDataAdapter
Dim myDatareader As OleDbDataReader
Dim myDataset As DataSet
'连接数据库
Public Function Conection(ByVal strConn)
myConnection = New OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA Source=" & strConn)
myConnection.Open()
End Function
'执行Select将结果放入DataSet并返回
Public Function ExecuteToDataAdapter(ByVal strSql, ByVal tb) As DataSet
myCommand = New SqlCommand(strSql, myConnection)
myDataadapter = New SqlDataAdapter(myCommand)
myDataset = New DataSet
myDataadapter.Fill(myDataset, tb)
Return myDataset
End Function
'执行Select语句
Public Function ExecuteQuery(ByVal strSql) As OleDbDataReader
myCommand = New OleDbCommand(strSql, myConnection)
myDatareader = myCommand.ExecuteReader()
Return myDatareader
End Function
'执行Update和Insert语句
Public Function ExecuteUpdate(ByVal strSql)
myCommand = New OleDbCommand(strSql, myConnection)
myCommand.ExecuteNonQuery()
End Function
'关闭数据库连接
Public Function Close()
myDatareader.Close()
myConnection.Close()
myConnection.Dispose()
End Function
'判断数据库中的字段是否为空
Public Function DbLen(ByVal Field As Object) As Integer
Dim len As Integer
Dim NewVar As String = ""
Dim ObjType As Type = Field.GetType()
If ObjType.FullName = "System.DBNull" Then
NewVar = Field.Value.ToString
Else
NewVar = Field
End If
Return NewVar.Length
End Function
End Class
'---------------------------------------------
'aspx调用 www.yemaosheng.com
'---------------------------------------------
<%@ Page Language="VB" Debug="true" %>
<%@ Import Namespace="DBConn" %>
<%@ Import Namespace="System.Data.OleDb" %>
<%@ Import Namespace="System.Data" %>
<%
Dim conn As New Conn()
Dim dtr As OleDbDataReader
Dim sql As String
conn.Conection(Request.ServerVariables("APPL_PHYSICAL_PATH") & "common\survey.mdb")
If request.Form("radio_survey")<>"" Then
sql="UPDATE tb_surveyitem SET surveyitem_item" & request.Form("radio_survey") & "=surveyitem_item" & request.Form("radio_survey") & "+1 WHERE surveyitem_survey=" & request.Form("hidden_surveyid")
conn.ExecuteUpdate(sql)
End If
dtr=conn.ExecuteQuery("select * from tb_survey,tb_surveyitem where survey_id=surveyitem_survey and survey_id=" & request.Form("hidden_surveyid"))
dtr.Read()
%>
<table width="500" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#333333">
<tr>
<td><table width="500" border="0" cellspacing="1" cellpadding"0">
<tr align="center">
<td colspan="2" bgcolor="#006699" class="title_text1"><strong><%=dtr("survey_title")%></strong></td>
</tr>
<%
Dim I As Integer
For I = 1 To 6
If conn.DbLen(dtr("survey_item" & I & "title")) > 0 then
%>
<tr>
<td width="100" bgcolor="#006699" class="title_text1"><%=dtr("survey_item" & I & "title")%></td>
<td width="400" bgcolor="#ECF9FF" valign=middle>
<img src='images/left-line.gif' width='<%=dtr("surveyitem_item" & I)*10%>' height=10>
</td>
</tr>
<%
End If
Next
%>
</table></td>
</tr>
</table>
<%
dtr.Close()
conn.Close()
%>
'---------------------------------------------
<TABLE cellSpacing=2 cellPadding=2 width=600 bgColor=#ffffff>
<TBODY>
<TR class="content_text1">
<TD bgColor=#bfd5e3 colSpan=6>招聘信息</TD>
</TR>
<%
Dim conn As New Conn()
Dim dtr As OleDbDataReader
conn.Conection(Request.ServerVariables("APPL_PHYSICAL_PATH") & "common\hr.mdb")
dtr=conn.ExecuteQuery("select * from tb_hr where hr_state=1")
While dtr.Read()
%>
<TR class="content_text1">
<TD width=10% bgColor=#e9e9e9>职位名称:</TD>
<TD width=50%><%=dtr("hr_job")%></TD>
<TD width=10% bgcolor="#E9E9E9">性别要求:</TD>
<TD width=10%><%=dtr("hr_gender")%></TD>
<TD width=10% bgcolor="#E9E9E9">招聘人数:</TD>
<TD width=10%><%=dtr("hr_num")%></TD>
</TR>
<TR class="content_text1">
<TD width=10% valign="top" bgColor=#e9e9e9>职位描述:</TD>
<TD colspan="5"><%=Replace(dtr("hr_desc"),vbCrLf,"<br>")%></TD>
</TR>
<TR class="content_text1">
<TD bgColor=#bfd5e3 colspan="6"> </TD>
</TR>
<%
End While
dtr.Close()
conn.Close()
%>
</TBODY>
</TABLE>
'---------------------------------------------
Dim conn As New Conn()
Dim ds As DataSet
Dim dr As DataRow
ds = conn.ExecuteToDataAdapter("select * from tb_board","board")
For Each dr In ds.Tables("board").Rows
response.write(dr("board_id"))
Next
Related Posts