这是错误:找不到表0。 [英] This is error :cannot find table 0.

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

问题描述

我有三个文本框

1)输入月份(从月份开始)

2)输入月份(到月份)

)输入年薪

然后我有一个名为(附表)的按钮

i当我点击此按钮显示弹出窗口并在此弹出窗口中显示一个gridview首先使用拖曳列:月份,2ed:工资
此网格中的
逐行排序

Ex:

如果我从月份输入1到7月

第一行的月份栏必须有

数字:1

2行:2

..... ect



我写了这段代码,但它不起作用



< b>我尝试了什么:



您好,感谢您的回复..但我有问题,但我不知道它是什么> >

我在按钮中尝试了这个代码(ButSchedule)

I have three textbox
1) to input the month (from month)
2) to input the month ( to month)
3) to input the Annual Salary
then i have a button named(Schedule)
i wanna when i click in to this button show a popup and in this popup a gridview with tow columns first:Month , 2ed:salary
in this grid the month sorting row by row
Ex:
if i input from month 1 to month 7
the month column the first row must have
number: 1
2ed row :2
..... ect

I wrote this code but it doesn't work

What I have tried:

Hi,thanks for reply ..but I have a problem but i don't know what is it >>
I tried this code in the button ("ButSchedule")

Dim con As New SqlConnection
Dim cmd As New SqlCommand("Finance")
Dim Adapter As New SqlDataAdapter
cmd.CommandType = CommandType.StoredProcedure
Dim ds As New DataSet
Dim dt As New DataTable
Dim constring = ConfigurationManager.ConnectionStrings("techConnectionString").ConnectionString()
con.ConnectionString = constring
cmd.Connection = con
Adapter.SelectCommand = cmd
cmd.Parameters.Add("@m", SqlDbType.Int)
cmd.Parameters("@m").Value = 1
Session("LoadData") = ds.Tables("tabel1")
con.Open()
Adapter.Fill(ds, "tabel1")
con.Close()
Dim x As Double
Session("fromMonth") = x
Dim y As Double
Session("toMonth") = y
Dim z As Double
If txtFrom.Text = "" Then
x = 0
Else
x = txtFrom.Text
End If
If txtTo.Text = "" Then
y = 0
Else
y = txtTo.Text
End If
If TextBox3.Text = "" Then
z = 0
Else
z = TextBox3.Text
End If
' Dim SUMSALARY As Integer
If Session("SUMSALARY") = ((z / 12) * (y - x + 1)) Then
ButSchedule.Attributes.Add("onclick", "window.open('salaryAA.aspx','','location=0,resizable=0,ScrollBars=1,statusbar=1,width=400,height=300,left=20,top=10,moveable=0') ;return false")
End If 



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

并且页面中的此代码必须显示为弹出窗口有网格视图::


------------------------------------------------------------
and this code in the page must display as a popup have a grid view ::

 Sub sorting() 

Dim ds As New DataSet
Dim dt As New DataTable

'GridView1.DataSource = ds.Tables("tabel1")
'GridView1.DataBind()
For i = Session("fromMonth") To Session("toMonth")
dt = ds.Tables(0)
Dim dr As DataRow = dt.NewRow()
dr("Month") = i
dr("Salary") = Session("SUMSALARY")
dt.Rows.Add(dr)
Session("LoadData") = dt
GridView1.DataSource = ds.Tables(0)
GridView1.DataBind()
Next

End Sub

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
sorting()

End If
End Sub

推荐答案

查看你的代码:

Look at your code:
Dim ds As New DataSet
Dim dt As New DataTable
 
'GridView1.DataSource = ds.Tables("tabel1")
'GridView1.DataBind()
For i = Session("fromMonth") To Session("toMonth")
dt = ds.Tables(0)

您创建一个新数据集 - 因此它将为空:

You create a new dataset - so it'll be empty:

Dim ds As New DataSet



然后尝试使用其中的第一个表:


And then try to use the first table in it:

dt = ds.Tables(0)

因为它是空的,所以第一个位置没有表,所以你得到运行时错误告诉你到底是这样:找不到表0。

您需要填充DataSet - 可能是从DB中填充 - 然后才能从中访问任何表。

Since it's empty, there is no table in the first position, so you get a run-time error telling you exactly that: "Cannot find table 0".
You need to populate your DataSet - probably from a DB - before you can access any tables from it.


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

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