找不到输入表 [英] cannot find the input table

查看:96
本文介绍了找不到输入表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在使用Visual Studio 2013,我已经使用3列在ms access 2007中创建了我的数据库。

在visual studio Form中,我已经制作了两个带有值的组合框和一个搜索框。还有一个文本框来显示结果。所以,我想要做的是,如果我从前两个组合框中选择值并单击搜索它应该在第三个文本框中显示结果。我的访问数据库非常简单



材料硬度材料代码

Hello everyone,
I am using Visual studio 2013 and i have made my database in ms access 2007 with 3 columns.
In visual studio Form, i have made two combo box with values in it and one search box. Also one text box to display the results.So, what i am trying to do is, if i select values from the first two combo box and click search it should display the result in third text box. My access database is quite simple

Material Hardness Material Code

Plain Carbon Steel ( AISI 1010- AISI 1030)	upto 150	H1
Plain Carbon Steel ( AISI 1010- AISI 1030)	150-180	        H2
Plain Carbon Steel ( AISI 1040- AISI 1060)	150-180	        H3
Plain Carbon Steel ( AISI 1040- AISI 1060)	180-220	        H4
Alloy steel (upto 3% carbon)	                 180-220	H4
Alloy steel (3% - 6% carbon)	                 180-220	H4
Alloy Steels ( upto 3% carbon)	                 220-300	H5
Alloy steel (3% - 6% carbon)	                 220-300	H5
Alloy Steel ( upto 3% carbon)	                 300-400	H6
Alloy steel (3% - 6% carbon)	                 300-400	H6







我想显示材料代码,如果我选择两个具有材料和硬度的组合框。



用VB编写链接到DB







Imports System.Data.OleDb

Public Class Form1

Dim v_HardnessDbconn As New OleDbConnection(Provider = Microsoft.ACE.OLEDB.12.0; DataSource = C:\ Users \Desktop \ Hardness.accdb)

Dim v_datareader作为OleDbDataReader



Private Sub Form1_Load(sender as Object ,e作为EventArgs)处理MyBase.Load

v_HardnessDbconn.Open()

v_HardnessDbconn.Close()

结束子





在搜索框上编码






I want to display material code, if i select two combo box with material and hardness.

coding in VB to link to DB



Imports System.Data.OleDb
Public Class Form1
Dim v_HardnessDbconn As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;DataSource=C:\Users\Desktop\Hardness.accdb")
Dim v_datareader As OleDbDataReader

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
v_HardnessDbconn.Open()
v_HardnessDbconn.Close()
End Sub


coding on the search box

    Private Sub searchtext_Click(sender As Object, e As EventArgs) Handles searchtext.Click
        
        TextBox1.Clear()
        Dim Str As String
 
        Str = "SELECT * From Items Where Material ='" & ComboBox1.Text & "' AND Hardness ='" & ComboBox2.Text & "'"
        Dim v_dbCommand As OleDbCommand
 
        v_dbCommand = New OleDbCommand(Str, v_HardnessDbconn)

v_HardnessDbconn.Open()
        Dim v_dataReader As OleDbDataReader = v_dbCommand.ExecuteReader()
        If v_dataReader.HasRows Then
            While v_dataReader.Read
                TextBox1.Text = "Material Code: " + v_dataReader.ToString(3)
 
            End While
            v_HardnessDbconn.Close()
v_dataReader.Close()
        End If
 

    End Sub
End Class







我得到的错误是这个:


Microsoft Office Access数据库引擎无法找到输入表或查询项。确保它存在并且其名称拼写正确。



我没有在visual studio中添加任何引用或任何其他内容。我不确定是否必须添加。

请查看我做错了什么。

i检查了文件名(硬度),看起来没问题。

谢谢




Error i am getting is this:

The Microsoft Office Access database engine cannot find the input table or query items. Make sure it exists and that its name is spelled correctly.

I haven't added any references or anything else in visual studio. I am not sure whether i have to add or not.
Please look into it what i am doing wrong.
i have checked the file name (Hardness) which looks alright.
thanks

推荐答案

首先将SQL语句与数据库表进行比较:

查找一个名为项目。

在该表中,查找名为Material的列,另一个名为Hardness。

如果所有这些都存在,请尝试调整 SQL只是:

Start by comparing your SQL statement with your database tables:
Look for a table called "Items".
In that table, look for a column called "Material" and another called "Hardness".
If all of that exists, try "tweaking" the SQL to just:
SELECT Material, Hardness FROM Items

看看你是否得到同样的错误。



但坦率地说,这不是一个好的数据库设计:你不应该保存相同信息的多个副本。您应该考虑使用材料表,硬度表等,并使用主表中的外键字段来链接。然后使用JOIN作为SELECT语句的一部分从表中获取。

And see if you get teh same error.

But frankly, that's not a good DB design: You shouldn't hold multiple copies of the same info. You should consider having a "Materials" table, a "Hardnesses" table and so on, and using foreign key fields in your primary table to "link back". And then use JOINs to fetch from the tables as part of your SELECT statements.


这篇关于找不到输入表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆