写的那个简繁转换程序,在将繁体字导入数据库时发生了超时错误。
用vbs更新实在太耗费时间了。.net有内存数据库一说,极大提高性能,我想这也许能解决问题。于是试验了下,终于成功了。
1.数据库内需要更新的表务必有主键
2.如果使用SqlCommandBuilder生成updatecommand,那么,务必在此之前将数据填进dataset.
example:Dim adpt As New SqlDataAdapter("select * from [gb_big5]", conn)
Dim ds As New DataSet()
adpt.Fill(ds, "[gb_big5]")
Dim objBui = New SqlCommandBuilder(adpt)
adpt.UpdateCommand = objBui.GetUpdateCommand()
adpt.InsertCommand = objBui.GetInsertCommand()
3.表名不能含有'-'横杠。否则更新报错(只用来显示不会报错)。
我终于成功更新了数据库,靠。在vs.net中开发,如果你绑定代码到.vb文件,引用类库里找不到sql.data.client,所以,在.vb里写的代码很多都被加上了波浪线。只好将代码搬进.aspx文件,去掉代码绑定,手工引入类库。
第一步怎么这么难啊,我搜了下帖子,N篇都是问dataset更新的问题,很多解决了的,很多没解决。
希望更新成功的人也接着发成功经验。
<%@Import Namespace="System" %>
<%@Import Namespace="System.IO" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<script language=vb runat = server>
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
Dim conn As New System.Data.SqlClient.SqlConnection
conn.ConnectionString = "Data Source=localhost;Initial Catalog=fschina;User Id=sa;Password=;"
conn.Open()
Dim adpt As New SqlDataAdapter("select * from [gb_big5]", conn)
Dim ds As New DataSet()
adpt.Fill(ds, "[gb_big5]")
Dim objBui = New SqlCommandBuilder(adpt)
adpt.UpdateCommand = objBui.GetUpdateCommand()
adpt.InsertCommand = objBui.GetInsertCommand()
ww("text info")
Dim stable As DataTable = ds.Tables("[gb_big5]")
call updatedb(stable)
adpt.Update(ds, "[gb_big5]")
Call outinfo(stable)
conn.Close()
End If
End Sub
Sub updatedb(ByVal stutable As DataTable)
Dim i, j As Int16
For i = 0 To 5
stutable.Rows(i).Item("big5_value") = "y"
Next
End Sub
Sub ww(ByVal te As String)
Response.Write(te)
End Sub
Sub outinfo(ByVal stutable As DataTable)
Dim i, j As Int16
ww("<table><TR>")
For i = 0 To stutable.Columns.Count - 1
ww("<TD>" & stutable.Columns(i).Caption & "</TD>")
Next
ww("</TR>")
For i = 0 To stutable.Rows.Count - 1
ww("<TR>")
For j = 0 To stutable.Columns.Count - 1
ww("<TD>" & stutable.Rows(i).Item(j) & "</TD>")
Next
ww("</TR>")
Next
ww("</table>")
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
End Sub
</script>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<FONT face="宋体">
<asp:Button id="Button1" style="Z-INDEX: 101; LEFT: 272px; POSITION: absolute; TOP: 88px" runat="server"
Text="Button" Width="144px" Height="64px"></asp:Button></FONT>
</form>
</body>
</HTML>
只可惜这年头,愿意指正别人的人越来越少了。