求助数据库更新问题!!急急!!在线等待
xivi 2003-08-19 10:16:17 Option Explicit On
Option Strict On
Imports System.Data
Imports System.Data.SqlClient
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows 窗体设计器生成的代码 "
Public Sub New()
MyBase.New()
'该调用是 Windows 窗体设计器所必需的。
InitializeComponent()
'在 InitializeComponent() 调用之后添加任何初始化
End Sub
'窗体重写处置以清理组件列表。
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Windows 窗体设计器所必需的
Private components As System.ComponentModel.IContainer
'注意:以下过程是 Windows 窗体设计器所必需的
'可以使用 Windows 窗体设计器修改此过程。
'不要使用代码编辑器修改它。
Friend WithEvents Label1 As System.Windows.Forms.Label
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.Label1 = New System.Windows.Forms.Label()
Me.SuspendLayout()
'
'Label1
'
Me.Label1.Font = New System.Drawing.Font("宋体", 14.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me.Label1.Location = New System.Drawing.Point(24, 16)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(96, 24)
Me.Label1.TabIndex = 0
Me.Label1.Text = "释放空间"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(136, 61)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Label1})
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim strcnn As String = "server=jet;database=powerscan;uid=psuser;password=psuser;"
Dim strSQL As String = "select free_space from ps_storage where lmod_user_id='1' and storage_id='1'"
Dim con As New SqlConnection(strcnn)
Dim DS As New DataSet()
Dim DA As SqlDataAdapter
Try
DA = New SqlDataAdapter(strSQL, con)
DA.Fill(DS, "ps_table")
Dim DT As DataTable
Dim DR As DataRow
DT = DS.Tables("ps_table")
DR = DT.NewRow()
Dim myDataRows() As DataRow
myDataRows = DT.Select("storage_id='1'") '问题出现在这句是找不到storage_id这列,但是我在数据库中,又事实上有这个字段。
myDataRows(0).Item("free_space") = "5000" ' 在这句中是说“未将对象引用设置到对象的实例”
'DR.Item("free_space") = "5000"
DA.Update(DS, "ps_table")
Catch er As Exception
MsgBox(er.Message)
End Try
End Sub
End Class
应该如何改???急!!