Dim num As Integer
成都創(chuàng)新互聯(lián)是一家集網(wǎng)站建設(shè),嘉黎企業(yè)網(wǎng)站建設(shè),嘉黎品牌網(wǎng)站建設(shè),網(wǎng)站定制,嘉黎網(wǎng)站建設(shè)報(bào)價(jià),網(wǎng)絡(luò)營(yíng)銷,網(wǎng)絡(luò)優(yōu)化,嘉黎網(wǎng)站推廣為一體的創(chuàng)新建站企業(yè),幫助傳統(tǒng)企業(yè)提升企業(yè)形象加強(qiáng)企業(yè)競(jìng)爭(zhēng)力??沙浞譂M足這一群體相比中小企業(yè)更為豐富、高端、多元的互聯(lián)網(wǎng)需求。同時(shí)我們時(shí)刻保持專業(yè)、時(shí)尚、前沿,時(shí)刻以成就客戶成長(zhǎng)自我,堅(jiān)持不斷學(xué)習(xí)、思考、沉淀、凈化自己,讓我們?yōu)楦嗟钠髽I(yè)打造出實(shí)用型網(wǎng)站。
Dim connstr, insertcmd, selectcmd As String
connstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\360data\重要數(shù)據(jù)\我的文檔\hd.mdb"
Dim conn As OleDbConnection
Dim cmd, cmd1 As OleDbCommand
conn = New OleDbConnection(connstr)
Dim r As OleDbDataReader
conn.Open()
insertcmd = "insert into returnbooks (aid,aname,ISBN,bname,renum,reday) values("
Val(ComboBox1.Text) ",'"
TextBox2.Text "','"
ComboBox2.Text "','"
TextBox2.Text "',"
Val(TextBox3.Text) ",'"
CType(TextBox4.Text, Date) "' )"
cmd = New OleDbCommand(insertcmd, conn)
cmd.ExecuteNonQuery()
updatecmd = "update books set remainnum=" Val(num) "-" Val(TextBox3.Text) " where ISBN='" ComboBox2.Text "'"
cmd = New OleDbCommand(updatecmd, conn)
cmd.ExecuteNonQuery()
updatecmd = "select remainnum as num from books where ISBN= '" ComboBox2.Text "'"
cmd = New OleDbCommand(updatecmd, conn)
cmd.ExecuteNonQuery()
updatecom = "update books set remainnum=num+ " Val(TextBox3.Text) ""
cmd = New OleDbCommand(updatecmd, conn)
cmd.ExecuteNonQuery()
selectcmd = "select remainnum from books where ISBN='" ComboBox2.Text "'"
cmd1 = New OleDbCommand(selectcmd, conn)
r = cmd1.ExecuteReader()
If (r.Read()) Then '如果sql查詢到了數(shù)據(jù)
num = r.GetInt32(0)
End If
conn.Close()
/*注意代碼的格式,不然改起來(lái)太費(fèi)時(shí)間*/
電子書太大,發(fā)布過(guò)去,樓主可以到網(wǎng)站上下載
;restype=-1id=10000001ty=0
中文的話,這里有個(gè)網(wǎng)站你可以去看看,上面搜羅了很多相關(guān)的書,
如果是英語(yǔ)的話,《Beginning VB.NET 2003》,作者:Thearon Willis, Jonathan Crossland, Richard Blair,其他信息:Wrox(出版社); 3 Sub edition | ISBN:0764556584 | 840 pages | April 9, 2004 | CHM | 32 Mb
使用System.XML
Imports Microsoft.VisualBasic
Imports System
Imports System.IO
Imports System.Xml
namespace HowTo.Samples.XML
public class WriteXmlFileSample
private const document as string = "newbooks.xml"
shared sub Main()
Dim myWriteXmlFileSample as WriteXmlFileSample
myWriteXmlFileSample = new WriteXmlFileSample()
myWriteXmlFileSample.Run(document)
end sub
public sub Run(args As String)
Dim myXmlTextReader as XmlTextReader = nothing
Dim myXmlTextWriter as XmlTextWriter = nothing
try
myXmlTextWriter = new XmlTextWriter (args, nothing)
myXmlTextWriter.Formatting = System.Xml.Formatting.Indented
myXmlTextWriter.WriteStartDocument(false)
myXmlTextWriter.WriteDocType("bookstore", nothing, "books.dtd", nothing)
myXmlTextWriter.WriteComment("此文件表示書店庫(kù)存數(shù)據(jù)庫(kù)的另一個(gè)片斷")
myXmlTextWriter.WriteStartElement("bookstore")
myXmlTextWriter.WriteStartElement("book", nothing)
myXmlTextWriter.WriteAttributeString("genre","autobiography")
myXmlTextWriter.WriteAttributeString("publicationdate","1979")
myXmlTextWriter.WriteAttributeString("ISBN","0-7356-0562-9")
myXmlTextWriter.WriteElementString("title", nothing, "The Autobiography of Mark Twain")
myXmlTextWriter.WriteStartElement("Author", nothing)
myXmlTextWriter.WriteElementString("first-name", "Mark")
myXmlTextWriter.WriteElementString("last-name", "Twain")
myXmlTextWriter.WriteEndElement()
myXmlTextWriter.WriteElementString("price", "7.99")
myXmlTextWriter.WriteEndElement()
myXmlTextWriter.WriteEndElement()
'向文件寫 XML 并關(guān)閉編寫器
myXmlTextWriter.Flush()
myXmlTextWriter.Close()
' 讀取返回的文件并進(jìn)行分析以確保正確生成 XML
myXmlTextReader = new XmlTextReader (args)
FormatXml (myXmlTextReader, args)
catch e as Exception
Console.WriteLine ("異常:{0}", e.ToString())
finally
Console.WriteLine()
Console.WriteLine("對(duì)文件 {0} 的處理已完成。", args)
If Not myXmlTextReader Is Nothing
myXmlTextReader.Close()
end if
'關(guān)閉編寫器
If Not myXmlTextWriter Is Nothing
myXmlTextWriter.Close()
end if
End try
End Sub
private shared Sub FormatXml (reader as XmlTextReader, filename as String)
Dim piCount, docCount, commentCount, elementCount as Integer
Dim attributeCount, textCount, whitespaceCount as Integer
While reader.Read()
Select (reader.NodeType)
case XmlNodeType.ProcessingInstruction:
Format (reader, "ProcessingInstruction")
piCount += 1
case XmlNodeType.DocumentType:
Format (reader, "DocumentType")
docCount += 1
case XmlNodeType.Comment:
Format (reader, "Comment")
commentCount += 1
case XmlNodeType.Element:
Format (reader, "Element")
elementCount += 1
While reader.MoveToNextAttribute()
Format (reader, "Attribute")
end While
if (reader.HasAttributes)
attributeCount += reader.AttributeCount
end if
case XmlNodeType.Text:
Format (reader, "Text")
textCount += 1
case XmlNodeType.Whitespace:
whitespaceCount += 1
End Select
End While
' 顯示該文件的統(tǒng)計(jì)信息
Console.WriteLine ()
Console.WriteLine("{0} 文件的統(tǒng)計(jì)信息", filename)
Console.WriteLine ()
Console.WriteLine("處理指令:" piCount)
Console.WriteLine("文檔類型:" docCount)
Console.WriteLine("注釋:" commentCount)
Console.WriteLine("元素:" elementCount)
Console.WriteLine("屬性:" attributeCount)
Console.WriteLine("文本:" textCount)
Console.WriteLine("空白:" whitespaceCount)
End Sub
private shared Sub Format(byref reader as XmlTextReader , NodeType as String)
' 格式化輸出
Console.Write(reader.Depth " ")
Console.Write(reader.AttributeCount " ")
Dim i as Integer
for i = 0 to reader.Depth - 1
Console.Write(Strings.chr(9))
Next
Console.Write(reader.Prefix NodeType "" reader.Name "" reader.Value)
Console.WriteLine()
End Sub
End Class
End Namespace
參考: