我获得的一个string量却不能加入到数据库中,为什么?

fileName = Path.GetFileNameWithoutExtension(files.Name)
fileType = Path.GetExtension(files.Name)
filePath = urlCanshu

Response.Write("

1<br/>

")
a = Mid(filePath, Len(rootDir) + 1, Len(filePath) - Len(rootDir))
urlPath = Replace(a, "", "/")
urlName = fileName & fileType

fileUrl = urlIp & urlPath & urlName

fileTime = File.GetLastWriteTime(filePath & fileName & fileType)

Dim row As DataRow = DataSet1.Tables("vod").NewRow()
row("vname") = fileName
row("vtype") = fileType
row("vpath") = filePath
row("vurl") = fileUrl
row("vtime") = fileTime
row("vclick") = 0
DataSet1.Tables("vod").Rows.Add(row)
SqlDataAdapter1.Update(DataSet1, "vod")
row.AcceptChanges()

“/WebApplication1”应用程序中的服务器错误。
--------------------------------------------------------------------------------

列“vtype”不属于表 vod。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。

异常详细信息: System.ArgumentException: 列“vtype”不属于表 vod。

源错误:

行 130: Dim row As DataRow = DataSet1.Tables("vod").NewRow()
行 131: row("vname") = fileName
行 132: row("vtype") = fileType
行 133: row("vpath") = filePath
行 134: row("vurl") = fileUrl

源文件: C:\Inetpub\wwwroot\WebApplication1\WebForm1.aspx.vb 行: 132

堆栈跟踪:

[ArgumentException: 列“vtype”不属于表 vod。]
System.Data.DataRow.set_Item(String columnName, Object value)
WebApplication1.WebForm1.Page_Load(Object sender, EventArgs e) in C:\Inetpub\wwwroot\WebApplication1\WebForm1.aspx.vb:132
System.Web.UI.Control.OnLoad(EventArgs e)
System.Web.UI.Control.LoadRecursive()
System.Web.UI.Page.ProcessRequestMain()

我的数据库中的vod的表定义的就是type列是char

---------------------------------------------------------------

看错,要改成*才行

SqlCommand1.CommandText = "SELECT * FROM vod WHERE (vname = '" & files.Name & " ')"

Published At
Categories with Web编程
Tagged with
comments powered by Disqus