Dim num As Integer
成都创新互联是一家集网站建设,嘉黎企业网站建设,嘉黎品牌网站建设,网站定制,嘉黎网站建设报价,网络营销,网络优化,嘉黎网站推广为一体的创新建站企业,帮助传统企业提升企业形象加强企业竞争力。可充分满足这一群体相比中小企业更为丰富、高端、多元的互联网需求。同时我们时刻保持专业、时尚、前沿,时刻以成就客户成长自我,坚持不断学习、思考、沉淀、净化自己,让我们为更多的企业打造出实用型网站。
Dim connstr, insertcmd, selectcmd As String
connstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\360data\重要数据\我的文档\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查询到了数据
num = r.GetInt32(0)
End If
conn.Close()
/*注意代码的格式,不然改起来太费时间*/
电子书太大,发布过去,楼主可以到网站上下载
;restype=-1id=10000001ty=0
中文的话,这里有个网站你可以去看看,上面搜罗了很多相关的书,
如果是英语的话,《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("此文件表示书店库存数据库的另一个片断")
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 并关闭编写器
myXmlTextWriter.Flush()
myXmlTextWriter.Close()
' 读取返回的文件并进行分析以确保正确生成 XML
myXmlTextReader = new XmlTextReader (args)
FormatXml (myXmlTextReader, args)
catch e as Exception
Console.WriteLine ("异常:{0}", e.ToString())
finally
Console.WriteLine()
Console.WriteLine("对文件 {0} 的处理已完成。", args)
If Not myXmlTextReader Is Nothing
myXmlTextReader.Close()
end if
'关闭编写器
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
' 显示该文件的统计信息
Console.WriteLine ()
Console.WriteLine("{0} 文件的统计信息", 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
参考: