问题描述
m_RowPosition的初始增量是通过fill命令通过从0开始填充虚拟表(如果可以调用它的话)来实现的.
我逐步完成了它,但看不到它告诉我我的价值观不会改变. . .我仍然是初学者,因此请在这里与我裸露.
嘿,我采纳了有关买书的建议,但是在遇到问题之后,我试图创建一个TEXBOX,该TEX将在数据库中查找多个字段,但始终返回相同的值. . .看一下代码,看看是否有人可以帮忙,
私有m_cnADONetConnection作为新的OleDb.OleDbConnection()
私有m_daDataAdapter作为OleDb.OleDbDataAdapter
私有m_cbCommandBuilder为OleDb.OleDbCommandBuilder
专用m_dtCD作为新数据表
昏暗的m_rowPosition为整数= 0
私有Sub StockDetailsForm_Load(按对象发送方为By,将发送方作为对象,按System.EventArgs为ByVal)处理Me.Load
m_cnADONetConnection.ConnectionString = _
"Provider = Microsoft.Jet.OLEDB.4.0;数据源= C:\ TEST.mdb"
m_cnADONetConnection.Open()
m_daDataAdapter =新的OleDb.OleDbDataAdapter("Select * From CD",m_cnADONetConnection)
m_cbCommandBuilder =新的OleDb.OleDbCommandBuilder(m_daDataAdapter)
m_daDataAdapter.Fill(m_dtCD)
公开子StockCheck()
StockEdit_Open_Conn()
Dim sql ="SELECT CouplingCode,AlbumTitle,ReleaseDate,TotalSongs,PPD from CD WHERE CouplingCode ="& StockDetailsForm.txtSearch.Text& ""
昏暗的cmd作为新的System.Data.OleDb.OleDbCommand
cmd =新的OleDbCommand(sql,m_cnADONetConnection)
Dim exReader As OleDbDataReader = cmd.ExecuteReader
m_cbCommandBuilder =新的OleDb.OleDbCommandBuilder(m_daDataAdapter)
私有Sub txtSearch_Leave(ByVal发送者为System.Object,ByVal e为System.EventArgs)处理txtSearch.Leave
试试
如果exReader.Read = False,则
MessageBox.Show(库存项目不存在",库存项目错误",MessageBoxButtons.OK,MessageBoxIcon.Stop)
m_cnADONetConnection.Close()
m_cnADONetConnection.Dispose()
其他
StockDetailsForm.CouplingCodeID.Text = _
m_dtCD.Rows(m_rowPosition)("CouplingCode").ToString()
StockDetailsForm.txtAlbumName.Text = _
m_dtCD.Rows(m_rowPosition)("AlbumTitle").ToString()
StockDetailsForm.txtPPD.Text = _
m_dtCD.Rows(m_rowPosition)("PPD").ToString()
StockDetailsForm.txtTotalSongs.Text = _
m_dtCD.Rows(m_rowPosition)("TotalSongs").ToString()
StockDetailsForm.dtpReleaseDate.Text = _
m_dtCD.Rows(m_rowPosition)("ReleaseDate").ToString()
StockDetailsForm.txtQtyHand.Text = _
m_dtCD.Rows(m_rowPosition)("QtyOnHand").ToString()
如果结束
End Sub
The initial incrementation of m_RowPosition came by the fill command by means of starting at 0 to fill my virtual table if would call it that
I stepped through it but I can''t see that it tells me that my values won''t change. . . Im still a beginner at this so please bare with me here.
Hey I took the advice on getting books but after that I am stuck , I am trying to create a TEXBOX that wil lookup mutiple fields in my DB but it always returns the same value. . . have a look at the code and see if anyone can help,
Private m_cnADONetConnection As New OleDb.OleDbConnection()
Private m_daDataAdapter As OleDb.OleDbDataAdapter
Private m_cbCommandBuilder As OleDb.OleDbCommandBuilder
Private m_dtCD As New DataTable
Dim m_rowPosition As Integer = 0
Private Sub StockDetailsForm_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
m_cnADONetConnection.ConnectionString = _
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\TEST.mdb"
m_cnADONetConnection.Open()
m_daDataAdapter = New OleDb.OleDbDataAdapter("Select * From CD", m_cnADONetConnection)
m_cbCommandBuilder = New OleDb.OleDbCommandBuilder(m_daDataAdapter)
m_daDataAdapter.Fill(m_dtCD)
Public Sub StockCheck()
StockEdit_Open_Conn()
Dim sql = "SELECT CouplingCode ,AlbumTitle ,ReleaseDate ,TotalSongs ,PPD FROM CD WHERE CouplingCode=''" & StockDetailsForm.txtSearch.Text & "''"
Dim cmd As New System.Data.OleDb.OleDbCommand
cmd = New OleDbCommand(sql, m_cnADONetConnection)
Dim exReader As OleDbDataReader = cmd.ExecuteReader
m_cbCommandBuilder = New OleDb.OleDbCommandBuilder(m_daDataAdapter)
Private Sub txtSearch_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtSearch.Leave
Try
If exReader.Read = False Then
MessageBox.Show("Stock Item does not exist", "Stock Item Error", MessageBoxButtons.OK, MessageBoxIcon.Stop)
m_cnADONetConnection.Close()
m_cnADONetConnection.Dispose()
Else
StockDetailsForm.CouplingCodeID.Text = _
m_dtCD.Rows(m_rowPosition)("CouplingCode").ToString()
StockDetailsForm.txtAlbumName.Text = _
m_dtCD.Rows(m_rowPosition)("AlbumTitle").ToString()
StockDetailsForm.txtPPD.Text = _
m_dtCD.Rows(m_rowPosition)("PPD").ToString()
StockDetailsForm.txtTotalSongs.Text = _
m_dtCD.Rows(m_rowPosition)("TotalSongs").ToString()
StockDetailsForm.dtpReleaseDate.Text = _
m_dtCD.Rows(m_rowPosition)("ReleaseDate").ToString()
StockDetailsForm.txtQtyHand.Text = _
m_dtCD.Rows(m_rowPosition)("QtyOnHand").ToString()
End If
End Sub
推荐答案
这篇关于RE:需要有关查找文本框的帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!