python 中出现 list index out of range错误

图片说明目的是实现当falsh中有相同元素时,arrow中相对应的元素相加,同样core中相对应的元素相加。图片说明这是我的程序,但是出现错误:图片说明
不知到怎么解决,新手谢各位大神

4个回答

查看你的i的值,当i为12时,i+1等于13,是否有对应的数据索引

if x[i] == x[i+1] 修改成 if i is not 13 and x[i] == x[i+1]

使用x+1在最后一个值处理会越界,需要进行判断

这个问题出现的原因主要是对python 中的区间理解错误,python 中的所有区间都是左闭右开的区间,range(1,4)表示的是1-3,而不是1-4
楼主的第13行代码明显没有考虑这种情况,当i为12时,i+1=13,显然越界了

使用x+1在最后一个值处理会越界,需要进行判断

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
list index out of range 求解
import os,re,linecacherndef fun(path):rn for root,dirs,files in os.walk(path):rn for fn in files:rn rootpath = os.path.join(root,fn)rn filetype=fn.split('.')[1]rn if filetype in['xml']:rn print(rootpath) rn new=(linecache.getline(rootpath,4)).rstrip()rn print (new)rn #print (type(new))rn newsp=new.split('.')rn #print (type(newsp))rn print(newsp[1])rn f= open(rootpath,'r+')rn d=f.read()rn open(rootpath, 'w').write(re.sub(r'a', 'b', d))rn f.close()rn else:rn continuernfun(r'C:\wmpub')rnrnrnrnC:\wmpub\a.xmlrnrnTraceback (most recent call last):rn File "C:\Documents and Settings\Administrator\桌面\test.py", line 21, in rn fun(r'C:\wmpub')rn File "C:\Documents and Settings\Administrator\桌面\test.py", line 14, in funrn print(newsp[1])rnIndexError: list index out of rangern>>>
python程序错误IndexError: list index out of range
新学习python这个问题总是没法解决希望大家帮帮忙rn源码:rn[code=python]#! /usr/bin/env pythonrn#coding=utf-8rnimport timernimport osrnstr1 = open( r'C:\Users\python\Desktop\url.txt' ,'r').readlines()rnnum = 0rnwhile num <= len(str1):rn com =r'"D:\Program Files (x86)\Mozilla Firefox\firefox.exe" %s'%(str1[num])rn print comrn os.system(com)rn num = num +1rn time.sleep(2)rnelse:rn print 'url open end!!!!'[/code]rnrnrnTraceback (most recent call last):rn File "D:\python_work\python\python\url.py", line 8, in rn com =r'"D:\Program Files (x86)\Mozilla Firefox\firefox.exe" %s'%(str1[num])rnIndexError: list index out of range
Python中遇到IndexError: list index out of range怎么解决
编码如下:rn# coding=gbkrnimport socketrnimport sysrns=socket.socket(socket.AF_INET, socket.SOCK_DGRAM)rn# 假设192.168.0.103是接收端机器的IP地址rns.sendto(sys.argv[1].encode(),("192.168.0.103" ,5000))rns.close()rn错误提示:rnTraceback (most recent call last):rn File "C:\Users\admin\eclipse-workspace\111\src\111.py", line 6, in rn s.sendto(sys.argv[1].encode(),("192.168.0.103" ,5000))rnIndexError: list index out of rangern请问怎么解决啊,谢谢啦
python爬虫中碰到IndexError: list index out of range问题
[code=python]soup = BeautifulSoup ( html, "lxml" )rntrs = soup.find_all('tr')[1:]rnmovies = []rnfor tr in trs:rn movie = rn tds = tr.find_all("td")rn title = tds[0].stringrn category = tds[1].stringrn nums = tds[2].stringrn city = tds[3].stringrn time = tds[4].stringrn movie['title'] = titlern movie['category'] = categoryrn movie['nums'] = numsrn movie['city'] = cityrn movie['time'] = timern movies.append(movie)rnprint(movies)[/code]rn代码如上,会显示如下错误:rn[code=python]Traceback (most recent call last):rn File "E:/资源/python 爬虫/bs4_hj/123123.py", line 138, in rn category = tds[1].stringrnIndexError: list index out of range[/code]rn小白技术有限,但是觉得应该是tds列表问题,但是不知道怎么修改,可以指导一下吗
python中 报错IndexError: list index out of range
listbuf是一个已知列表rnnumb=1rnlist1=[]rnwhile numb<=len(listbuf):rn list1.append(listbuf[numb])rn numb+=1rn报错:IndexError: list index out of rangern当numb+=1改为numb+=2又不会报错,这是为什么。rn怎样做才能在用numb+=1的时候不报错
出现"List index out of bounds(-1)"错误?
在一个无限下级树的树的生成中,下面代代码出错了,rn提示: List index out of bounds(-1) ,没看到错在哪啊?rnrn Node := TreeView.Items.AddChildObjectFirst(TTreeNode(List.Objects[Index]),rn Query.FieldByName('Dname').AsString, query.GetBookmark);
TListView出现List index out of bounds 错误
启动计时器每20秒读数据库,将数据显示在lvHTTPPerf中,但经常每次计时器刷新都弹出rnList index out of bounds (-1)错误对话框,有时候又不出现,请问是什么原因?如何解决该问题。rn .... rn adoqRealPerf->Open();rn adoqRealPerf->First();rn lvHTTPPerf->Clear();rn TListItem *ListItem;rn while(!adoqRealPerf->Eof)rn rn ListItem = lvHTTPPerf->Items->Add();rn ListItem->Caption = adoqRealPerf->FieldByName("TESTNO")->AsString;rn ListItem->SubItems->Add(adoqRealPerf->FieldByName("RECVTIME")->AsString);rn ListItem->SubItems->Add(adoqRealPerf->FieldByName("DNSTIME")->AsString);rn ListItem->SubItems->Add(adoqRealPerf->FieldByName("CONNECTTIME")->AsString);rn ListItem->SubItems->Add(adoqRealPerf->FieldByName("RESPONSETIME")->AsString);rn ListItem->SubItems->Add(adoqRealPerf->FieldByName("TRANSACTTIME")->AsString);rn ListItem->SubItems->Add(adoqRealPerf->FieldByName("DOWNLOADRATE")->AsString);rn adoqRealPerf->Next();rn
求助:IndexError: list index out of range
使用Spyder(python 3.6)代码为:rn#!/usr/bin/env python3rnimport sysrnrnfrom xlrd import open_workbookrnfrom xlwt import Workbookrnrninput_file = sys.argv[1]rnoutput_file = sys.argv[2]rnrnoutput_workbook = Workbook()rnoutput_worksheet = output_workbook.add_sheet('jan_2013_output')rnrnwith open_workbook(input_file) as workbook:rn worksheet = workbook.sheet_by_name('january_2013')rn for row_index in range(worksheet.nrows):rn for column_index in range(worksheet.ncols):rn output_worksheet.write(row_index, column_index, worksheet.cell_value(row_index, column_index))rnoutput_workbook.save(output_file)rnrn执行:python 2excel_parsing_and_write.py sale_2013 Loutput.xlsrnrn出现问题,输出;rnPython 3.6.2 |Anaconda custom (64-bit)| (default, Sep 19 2017, 08:03:39) [MSC v.1900 64 bit (AMD64)]rnType "copyright", "credits" or "license" for more information.rnrnIPython 6.1.0 -- An enhanced Interactive Python.rnrnrnrnrunfile('C:/LearnPython/excel/2excel_parsing_and_write.py', args='sales_2013.xlsx', wdir='C:/LearnPython/excel')rnTraceback (most recent call last):rnrn File "", line 1, in rn runfile('C:/LearnPython/excel/2excel_parsing_and_write.py', args='sales_2013.xlsx', wdir='C:/LearnPython/excel')rnrn File "H:\ProgramData\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 710, in runfilern execfile(filename, namespace)rnrn File "H:\ProgramData\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 101, in execfilern exec(compile(f.read(), filename, 'exec'), namespace)rnrn File "C:/LearnPython/excel/2excel_parsing_and_write.py", line 8, in rn output_file = sys.argv[2]rnrnIndexError: list index out of range
Bits index out of range
对 Delphi 5 ClientDataSet, Edit操作, Post时报错 Bits index out of range, insert时正常, 不知是何原因?
"DBGrid index Out of Range "
Query1->DisableControl();rnfor(int i=0; i<100; i++)rnrn Query1->Append();rn Query1->FiledByName("f1")->Value="sss";rn Query1->FiledByName("f2")->Value="sss1";rn Query1->Post();rnrnQuery1->EnableControl();rnrn为什么加上 :rnQuery1->DisableControl();rnQuery1->EnableControl();rn时有时候会出现"DBGrid index Out of Range " 错误!rn
脚本报错:IndexError: list index out of range
[code=Python]j=0rnd=os.listdir(DBDIR)rnfor j in range(0,len(d)-1):rn if d[j][-3:] != 'sql':rn del d[j][/code]rnrnrn这段代码为什么总是报IndexError: list index out of range啊rnrn调试了一下,发现出错后,j的值是301rnrn但我led(d)值是300,我已经限制range(0,299),为什么j值会超出啊rn
Python2.7:数据清洗的list index out of range问题
```rnfrom csv import readerrnrndata_rdr = reader(open('mn.csv','rb'))rnheader_rdr = reader(open('mn_headers.csv','rb'))rnrndata_rows = [d for d in data_rdr]rnheader_rows = [h for h in header_rdr]rnrnbad_rows = []rnrnfor h in header_rows:rn if h[0] not in data_rows[0]:rn bad_rows.append(h)rnrnfor h in bad_rows:rn header_rows.remove(h)rnrnprint len(header_rows)rnrn Traceback (most recent call last):rn File "/home/sewell-hoo/datafiles/test_listindex.py", line 12, in rn if h[0] not in data_rows[0]:rnIndexError: list index out of rangern```rn正在读《python数据处理》一书,这是第7章第2小节的内容:rn处理2个CSV文件,却一直提示List index out of range,实在是想不到哪里错了。rn请忽略图中配图的文件'mn_header_update.csv',两者是一个文件rnrn![图片说明](https://img-ask.csdn.net/upload/201711/06/1509974191_107534.png)
Python3 Error: list index out of range
[code=python]rnrnf = open ('userinfo.txt')#flie_adrnlines = f.readlines()rnnum_f = 0rnnum_m = 0rnfor i in lines:rn name = i.split(',')[0]rn birthday = i.split(',')[1]rn print(name,birthday)rn if i.split(',')[2] == 'male':rn num_m = num_m+1rn else:rn num_f = num_f +1rnprint ("There is %d male emp" %num_m)rnprint ("There is %d emp in this office" %(num_m+num_f))rnrn[/code]rnrn[code=text]rnuserinfo.txtrnrnfox,1995,male,rnhanmeimei,1990,female,rnliming,1989,male,rnasdf,1995,female,rn[/code]rnrnrn执行结果为 rn[code=python]rnfox 1995rnhanmeimei 1990rnliming 1989rnasdf 1995rnTraceback (most recent call last):rn Flie "test.py", line 14, in rn birthday = i.split(',')[1]rnIndexError: list index out of rangern[/code]rnrn这个报错无法理解 15行print已经成功输出了 反过头说14行超限了rnrnpython版本是3.5.0 rn系统是Red Hat Enterprise Linux 6rn用vim编译
grid index out of range
beginrn dmData.adoQCode.open;rn dmData.adoQCode.Append;rn dmData.adoQCode.FieldByName('Type').AsString := cbbType.Text;rn dmData.adoQCode.FieldByName('Value').AsString := edtValue.Text;rn dmData.adoQCode.FieldByName('Mem').AsString := edtMem.Text;rn dmdata.adoQCode.Post;rn end;rn我用的是DBgrid和Access库,在添加一条记录时报出grid index out of range 的错误,请各位知道的加以指点
index out of range exception??
index out of range exception??rnrn[color=#FF0000]error code:rnrn if (!Convert.IsDBNull(reader["Name"]))rn username = reader["Name"].ToString();[/color]rnrnrn2. source code:rnrn public bool LoginUser(string username,string pwd)rn rn rn bool exists = false;rn SqlParameter[] parms = new SqlParameter[2];rn parms[0] = new SqlParameter("@name", SqlDbType.NVarChar, 100);rn parms[1] = new SqlParameter("@password", SqlDbType.NVarChar, 100);rn parms[0].Value = username;rn parms[1].Value = pwd;rn SqlDataReader reader = DbTools.ExecuteReader("LoginUserProce", parms);rnrn if (reader.Read())rn rn[color=#339966] exists = true;rn if (!Convert.IsDBNull(reader.GetValue(2)))[/color]???????????????rn username = reader.GetValue(2).ToString();rn if (!Convert.IsDBNull(reader["password"]))rn pwd = reader["password"].ToString();rn rn rn reader.Close();rn return exists;rnrn rnrnrn
爬取淘宝评论时出现list index out of range问题
list index out of range  列表越界Traceback (most recent call last):  File &quot;G:/workSpace/Python/TB_Crawler/Crawler_train.py&quot;, line 71, in &amp;lt;module&amp;gt;    print(getCommentsList(ItemURL2))  File &quot;G:/workSp...
java.lang.StringIndexOutOfBoundsException: String index out of range: -1错误
[img=https://img-bbs.csdn.net/upload/201704/14/1492166177_246376.png][/img][img=https://img-bbs.csdn.net/upload/201704/14/1492166190_367039.png][/img]rnrn //向服务器获取根目录rn public static String getRootList() throws Exceptionrn String json = "\"type\":\"getRootList\"";rn output.write(json.getBytes());rn output.flush();rn byte[] b = new byte[1024];rn int len = input.read(b);rn json = new String(b,0,len);//字符串进行转化rnrn Config.ROOT_LIST_JSON_STR = json;rn return json; rn rn[img=https://img-bbs.csdn.net/upload/201704/14/1492166266_975276.png][/img]rntry rn String json_str = Config.service.getRootList();rn System.out.println(json_str);rn JSONObject json = JSONObject.fromObject(json_str);//对json的解析rn rn JSONArray jsonArray_mulu = json.getJSONArray("mulu");rn JSONArray jsonArray_files = json.getJSONArray("files");rn rn this.removeAll();rn rn int count = jsonArray_mulu.size()+jsonArray_files.size();rn rn for (int i = 0; i < jsonArray_mulu.size(); i++) rn JSONObject mulu = jsonArray_mulu.getJSONObject(i);rn rn this.add(new FileJPanel(mulu.getString("rdid"), mulu.getString("did"), "DIR", mulu.getString("dname")));rn rn rn for (int i = 0; i < jsonArray_files.size(); i++) rn JSONObject file = jsonArray_files.getJSONObject(i);rn this.add(new FileJPanel(file.getString("did"), file.getString("fid"), "FILE", file.getString("fname")));rn rn rn rn this.setPreferredSize(new Dimension(508,(count/5+(count%5==0?0:1))*135));rn catch (Exception e) rn // TODO Auto-generated catch blockrn e.printStackTrace();rn javax.swing.JOptionPane.showMessageDialog(this.getParent(), "网络异常,请稍后再试");rn rn相关的代码贴出来了,但不是很理解这个数组怎么就越界了。也不知道怎么去修改
String index out of range: -6 的错误
初次使用hibernate,然后将一个页面中的数据插入到数据库中时,就阴魂不散的发生了这个错误,我插入的值只是一位:“1”,却总是报这个错,有谁也碰到过这个问题吗?
python列表删除会出现一个错误 list index out of range
1,这是列表在删除的时候出现的一个问题,目的是为了删除列表中的0元素# _*_ coding:utf-8 _*_ # __author__ = 'dragon' P = [0, 1, 2, 2, 2, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 2, 0, 1, 0, 44, 1, 0] for i in range(0,len(P)-1): if(P[i] ==
用list存储数据,老是IndexError: list index out of range
在这里询问之前我查询了相关说法,[color=#FF0000][url=http://bbs.chinaunix.net/viewthread.php?tid=930944]看这里[/url][/color]rn我觉得我的故障也是因为一位老兄下面的说法:rn>看最后的提示是下标超出范围 rn>比喻a只有10个元素 如果a[11]就是这种错误 rnrn我的代码如下:rn[code=Python]rncontent = []rnfor x in tmp3: #这里tmp3里面是由re.findall()找到的字符串,一般有1~5条的字符串rn content[number].extend(x) #而每个1~5条字符串我要全部依次存到content[0],content[1],content[2],......当中去rn #如果改成content.append(x)当然okrn #但是不符合我的要求了~~rn[/code]rnrn最后我要得到的是:rn[code=Python]rn>>>contentrn[["xxxxxx","xxx","yy","xcdfsdgf"],["dfsdf","sdfsdfsdf"
String index out of range: 6
[img=https://img-bbs.csdn.net/upload/201305/18/1368875784_483066.png][/img]rn[img=https://img-bbs.csdn.net/upload/201305/18/1368875946_841555.png][/img]rn[img=https://img-bbs.csdn.net/upload/201305/18/1368875959_219033.png][/img]rnrnrn老是说 字符串索引超出范围 到底哪里错了????
奇怪的 String index out of range
int chars = newsform.getContent().length(); //总字符数 intrn int PerPage = 1000; //每页要分的字符数rn int allpage; //总页数rnrn allpage = (chars + PerPage - 1) / (PerPage); //取得总页数rn rn String str[] = new String[allpage];rnrn String news = getStr(newsform.getContent());rn System.out.println(allpage+"页");rn System.out.println(chars+"个字符");rn for (int i = 0; i < allpage; i++) rn rn if (i==allpage-1) rn rn str[i] = news.substring((i * PerPage));rn System.out.println(str[i].length());rn rn else rn rn str[i] = news.substring((i * PerPage), ((i + 1) * PerPage));rn System.out.println("第"+i+"次"+str[i].length());rn rnrn rn rn打印出:rn6页rn5191个字符rn第0次1000rn第1次1000rn第2次1000rn第3次1000rnrn这是错误:String index out of range: 5000rnrn帮我看下怎么会错的?
String index out of range: -1
String index out of range: -1rnrn是怎么回事啊 rnrn谢谢
Row index out of range问题
public class Table1 extends JFramern String rid[] = new String[100];rn int count = 0;rn /*rn * public static void main(String a[]) new Table1(); rn */rn rn public void center(JFrame frame) rn double x = frame.getWidth(); // 居中困难rn double y = frame.getHeight();rn Toolkit kit = Toolkit.getDefaultToolkit();rn Dimension screenSize = kit.getScreenSize();rn double xx = screenSize.getWidth();rn double yy = screenSize.getHeight();rn frame.setLocation((int) (xx / 2 - x / 2), (int) (yy / 2 - y / 2));rn rn public Table1() rn JPanel zuida = new JPanel(new BorderLayout(0, 10));rn JPanel jp1 = fangzi();rn JPanel jp2 = dingdan();rn jp2.setBorder(BorderFactory.createTitledBorder("订单信息"));rn JTabbedPane tp = new JTabbedPane();rn tp.addTab("房间预定", jp1);rn tp.addTab("订单信息", jp2);rn // zuida.add(jp1);rn zuida.add("North", tp);rn JFrame frame = new JFrame("酒店");rn frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);rn //zuida.setBackground(new Color(102,204,255)); 设置背景颜色rn zuida.setBorder(new EmptyBorder(5, 5, 5, 5));rn frame.setContentPane(zuida);rn frame.setVisible(true);rn frame.pack();rn center(frame);rn System.out.println("123");rn // frame.setLocationRelativeTo(null);//这个也是居中的方法rn rn JPanel fangzi() rn JTable jiu = jiudian();rn JTable table = order();rn JScrollPane pane = new JScrollPane(jiu); // 加滑轮rn JPanel panel = new JPanel();//rn JPanel panel2 = new JPanel(new FlowLayout(FlowLayout.CENTER, 30, 10));rn JPanel panel3 = new JPanel(new GridLayout(1, 10));rn JPanel panel4 = new JPanel(new BorderLayout(0, 10));rn panel.setPreferredSize(new Dimension(600, 400));rn panel.setLayout(new BorderLayout());rn JButton b1 = new JButton("预订");rn JButton b2 = new JButton("加至购物车");rn JButton b3 = new JButton("预定多个");rn JButton b4 = new JButton("生成订单");rn panel2.add(b1);rn panel2.add(b2);rn panel2.add(b3);rn panel2.add(b4);rn ButtonListener bListener = new ButtonListener(jiu,rid);rn rn JButton b5 = new JButton("查询空房");rn panel3.add(b5);rn rn rn bListener.jPanel = panel;rn bListener.jPanel2 = pane;rn ButtonListener bListener2 = new ButtonListener(table);rn b5.addActionListener(bListener2);rn rn b1.addActionListener(bListener);rn b2.addActionListener(bListener);rn b3.addActionListener(bListener);rn b4.addActionListener(bListener);rnrn panel.add("Center", pane);rn panel.add("South", panel2);rn panel.add("North", panel3);rn panel.setBorder(BorderFactory.createTitledBorder("房间信息"));rn rn rn rn return panel;rn rn JPanel dingdan() rn JTable dingdan = order();rn JScrollPane pane = new JScrollPane(dingdan);rn JPanel jp10 = new JPanel(new BorderLayout());rn jp10.add("Center", pane);rn JButton b1 = new JButton("确定");rn JButton b2 = new JButton("刷新");rn jp10.add("South", b1);rn jp10.add("North",b2);rn ButtonListener bListener1 = new ButtonListener(dingdan);rn b1.addActionListener(bListener1);rn b2.addActionListener(bListener1);rn return jp10;rn rn JTable order() //生成订单的表格rn Vector lieV = new Vector();rn Vector hangV = new Vector();rn try rn Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");rn Connection con;rn con = DriverManager.getConnection("jdbc:sqlserver://localhost:1433;DataBaseName=Hotel", "sa", "123");rn PreparedStatement statement = con.prepareStatement("Select * from 订单 where Userid =? ");rn statement.setString(1, new MainClass().getname());rn ResultSet rs = statement.executeQuery();rn while (rs.next()) rn Vector hangv = new Vector();rn hangv.add(Integer.parseInt(rs.getString(1)));rn hangv.add(rs.getString(2)); rn hangv.add((rs.getString(3))); rn hangv.add((rs.getString(4))); rn hangv.add((rs.getInt(5))); rn hangv.add((rs.getString(6))); rn hangv.add((rs.getInt(7)));rn hangV.add(hangv);rn rn catch (Exception e) rn System.out.println("Error" + e);rn rn final Object Lie[] = "订单编号", "用户", "房间编号", "订单日期","数量", "状态","价格" ;rn lieV.add("订单编号");rn lieV.add("用户");rn lieV.add("房间编号");rn lieV.add("订单日期");rn lieV.add("数量");rn lieV.add("状态");rn lieV.add("价格");rn rn //JTable jiu = new JTable(row, Lie); // 建立表格rn DefaultTableModel tableModel = new DefaultTableModel(hangV, lieV);rn JTable jiu = new JTable(tableModel); rn jiu.setPreferredScrollableViewportSize(new Dimension(400, 300));rn jiu.setRowHeight(30);rn jiu.setRowMargin(5);rn jiu.setRowSelectionAllowed(true);rn jiu.setSelectionBackground(Color.WHITE);rn jiu.setSelectionForeground(Color.red);rn jiu.setGridColor(Color.BLACK);rn // jiu.selectAll();rn jiu.setRowSelectionInterval(0, 0);rnrn //jiu.clearSelection();rn jiu.setDragEnabled(false);rn jiu.setShowGrid(true);rn jiu.setShowHorizontalLines(false);rn jiu.setShowVerticalLines(false);rn //jiu.doLayout();rn jiu.setBackground(Color.LIGHT_GRAY);rn //ButtonListener bListener = new ButtonListener(jiu, rid);rn //bListener.otherTable = jiu;rn return jiu;rn rn //!!!!rn JTable jiudian() //生成酒店的表格 rn // 用向量来实现动态的大小rn //Object 可以不用了rn Vector lieV = new Vector();rn Vector hangV = new Vector();rn Object row[][] = new Object[30][30];rn try rn Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");rn Connection con;rn con = DriverManager.getConnection("jdbc:sqlserver://localhost:1433;DataBaseName=Hotel", "sa", "123");rn Statement statement = con.createStatement();rn ResultSet rs = statement.executeQuery("Select * from 房间");rn int x = 0;rn int y = 0;rn rn while (rs.next()) rn Vector hangv = new Vector();rn row[x][y] = Integer.parseInt(rs.getString("rid"));rn hangv.add(row[x][y]);rn y++;rn row[x][y] = rs.getInt("Rprice");rn hangv.add(row[x][y]);rn y++;rn row[x][y] = (rs.getString("raddress"));rn hangv.add(row[x][y]);rn y++;rn row[x][y] = (rs.getString("rtype"));rn hangv.add(row[x][y]);rn y++;rn row[x][y] = (rs.getString("rstate"));rn hangv.add(row[x][y]);rn x++;rn y = 0;rn hangV.add(hangv);rn rn catch (Exception e) rn System.out.println("Error" + e);rn rn final Object Lie[] = "编号", "价格", "位置", "类型", "状态" ;rn lieV.add("编号");rn lieV.add("价格");rn lieV.add("位置");rn lieV.add("类型");rn lieV.add("状态");rn rn //JTable jiu = new JTable(row, Lie); // 建立表格rn DefaultTableModel tableModel = new DefaultTableModel(hangV, lieV);rn JTable jiu = new JTable(tableModel); rn jiu.setPreferredScrollableViewportSize(new Dimension(400, 300));rn jiu.setRowHeight(30);rn jiu.setRowMargin(5);rn jiu.setRowSelectionAllowed(true);rn jiu.setSelectionBackground(Color.WHITE);rn jiu.setSelectionForeground(Color.red);rn jiu.setGridColor(Color.BLACK);rn // jiu.selectAll();rn jiu.setRowSelectionInterval(0, 0);rnrn //jiu.clearSelection();rn jiu.setDragEnabled(false);rn jiu.setShowGrid(true);rn jiu.setShowHorizontalLines(false);rn jiu.setShowVerticalLines(false);rn jiu.doLayout();rn jiu.setBackground(Color.LIGHT_GRAY);rnrn return jiu;rn rnrnrnrnrnErrorjava.lang.IllegalArgumentException: Row index out of rangern实在不知道怎么修改rn
Parameter index out of range 谢谢!
谢谢大家!帮我看看这个错误怎么回事,谢谢!!rnrnjava.sql.SQLException: Parameter index out of range (1 > number of parameters, which is 0).rn at com.mysql.jdbc.PreparedStatement.setInternal(PreparedStatement.java:2493)rn at com.mysql.jdbc.PreparedStatement.setString(PreparedStatement.java:3213)rn at database.LinkDB.addBook(LinkDB.java:35)rn at action.addBookAction.execute(addBookAction.java:37)rn at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:421)rn at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:226)rn at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)rn at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:415)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)rn at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)rn at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)rn at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)rn at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)rn at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)rn at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)rn at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)rn at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)rn at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)rn at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)rn at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)rn at java.lang.Thread.run(Thread.java:595)rn
String index out of range: 48
String index out of range: 48
list index out of bounds
unit Unit6;rnrninterfacernrnusesrn Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,rn Dialogs, StdCtrls, ComCtrls, DB, ADODB, Grids, DBGrids, ToolWin,hotelmodual,rn Menus;rnrntypern TForm6 = class(TForm)rn ToolBar1: TToolBar;rn ToolButton1: TToolButton;rn ToolButton2: TToolButton;rn ToolButton3: TToolButton;rn ToolButton4: TToolButton;rn ToolButton5: TToolButton;rn ToolButton6: TToolButton;rn ADOQuery1: TADOQuery;rn ADOTable1: TADOTable;rn DBGrid1: TDBGrid;rn DataSource1: TDataSource;rn PageControl1: TPageControl;rn GroupBox1: TGroupBox;rn Label1: TLabel;rn Label2: TLabel;rn Label3: TLabel;rn Label4: TLabel;rn Label5: TLabel;rn Label6: TLabel;rn Edit1: TEdit;rn Edit2: TEdit;rn Edit3: TEdit;rn Edit4: TEdit;rn Edit5: TEdit;rn Edit6: TEdit;rn PopupMenu1: TPopupMenu;rn procedure FormShow(Sender: TObject);rn procedure ToolButton1Click(Sender: TObject);rn procedure ToolButton2Click(Sender: TObject);rn procedure Edit1KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);rn procedure ToolButton3Click(Sender: TObject);rn procedure ToolBar1Click(Sender: TObject);rn procedure ADOTable1AfterScroll(DataSet: TDataSet);rn procedure ToolButton5Click(Sender: TObject);rn procedure ToolButton6Click(Sender: TObject);rn privatern Private declarations rn pmark:integer;rn function ptest():string;rnrn publicrn Public declarations rn end;rnrnvarrn Form6: TForm6;rnrnimplementationrnrnuses Unit3;rnrn$R *.dfmrnrnprocedure TForm6.ADOTable1AfterScroll(DataSet: TDataSet);rnbeginrnedit1.Text:=adotable1.FieldByName('roomid').AsString;rnedit2.Text:=adotable1.FieldByName('roomtype').AsString;rnedit3.Text:=adotable1.FieldByName('tvor').AsString;rnedit4.Text:=adotable1.FieldByName('airconditionaryor').AsString;rnedit5.Text:=adotable1.FieldByName('netor').AsString;rnedit6.Text:=adotable1.FieldByName('price').AsString;rnrnedit1.ReadOnly:=true;rnedit2.ReadOnly:=true;rnedit3.ReadOnly:=true;rnedit4.ReadOnly:=true;rnedit5.ReadOnly:=true;rnedit6.ReadOnly:=true;rn pmark:=2;rnend;rnrnprocedure TForm6.Edit1KeyDown(Sender: TObject; var Key: Word;rn Shift: TShiftState);rn varrn x,x1:integer;rn tc:tcomponent;rn beginrn if not (ActiveControl is TDBGrid) thenrn beginrn if (key=13)or(key=vk_down) thenrn beginrn perform (WM_NEXTDLGCTL,0,0);rn end;rn if key=VK_UP then perform(WM_NEXTDLGCTL,1,0);rn end;rnend;rnrnprocedure TForm6.FormShow(Sender: TObject);rnvarrn i:integer;rnbeginrn adoquery1.Connection:=datamodule3.ADOConnection1;rn adotable1.connection:=datamodule3.ADOConnection1;rnrn adotable1.Close;rn adotable1.TableName:='room';rn adotable1.Open;rnrn with dbgrid1 dorn beginrn columns.clear;rnrnfor i := 0 to 5 do columns.Add;rn columns[0].Title.caption:='房间号';rn columns[1].Title.caption:='房间类型';rn columns[2].Title.caption:='是否有电视';rn columns[3].Title.caption:='是否有空调';rn columns[4].Title.caption:='是否有宽带';rn columns[5].Title.caption:='价格';rnrn columns[0].fieldname:='roomid';rn columns[1].fieldname:='roomtype';rn columns[2].fieldname:='tvor';rn columns[3].fieldname:='airconditionaryor';rn columns[4].fieldname:='netor';rn columns[5].fieldname:='price';rnrn columns[0].Width:=40;rn columns[1].Width:=100;rn columns[2].Width:=80;rn columns[3].Width:=100;rn columns[4].Width:=60;rn columns[5].Width:=60;rnrn for I := 0 to 5 dorn beginrn Columns[i].Title.Alignment:=tacenter;rn end;rn//options:=options-[dgediting];rn end;rn pagecontrol1.Pages[0].Caption:='房间信息';rn pagecontrol1.activepageindex:=0;rn dbgrid1.popupmenu:=popupmenu1;rn pmark:=0;rnrnend;rnrnprocedure TForm6.ToolBar1Click(Sender: TObject);rnvarrns,s1,s2:string;rnn:integer;rnbeginrn s:=ptest();rn if(s='')thenrn beginrn adotable1.AfterScroll:=nil;rn n:=0;rn if(pmark=1) then adotable1.Append;rnrn adotable1.Edit;rn adotable1.FieldByName('roomid').AsString:=trim(edit1.text);rn adotable1.fieldbyname('roomtype').AsString:=trim(edit2.text);rn adotable1.fieldbyname('tvor').AsString:=trim(edit3.Text);rn adotable1.fieldbyname('airconditionaryor').AsString:=trim(edit4.text);rn adotable1.fieldbyname('netor').AsString:=trim(edit5.text);rn adotable1.fieldbyname('price').AsString:=trim(edit6.text);rn adotable1.Post;rn pmark:=2;rn adotable1.AfterScroll:=adotable1.afterscroll;rn endrn elsern beginrn s:='数据验证发现以下错误:'+char(13)+s+char(13)+char(13)+'数据保存失败!';rn application.MessageBox(pchar(s),'系统提示',0+16);rn end;rnend;rnrnprocedure TForm6.ToolButton1Click(Sender: TObject);rnvarrni:integer;rnbeginrn for i := 1 to 6 dorn beginrn tedit(findcomponent('edit'+inttostr(i))).Text:='';rn tedit(findcomponent('edit'+inttostr(i))).readonly:=false;;rn end;rn edit1.SetFocus;rn pmark:=1;rn pagecontrol1.ActivePageIndex:=0;rnend;rnrnprocedure TForm6.ToolButton2Click(Sender: TObject);rnvarrni:integer;rns:string;rnbeginrn for i:= 1 to 6 dorn beginrn s:='edit'+inttostr(i);rn tedit(findcomponent(s)).ReadOnly:=false;rn end;rn edit1.readonly:=true;rn pmark:=2;rnend;rnrnprocedure TForm6.ToolButton3Click(Sender: TObject);rnvarrnx:integer;rnbeginrn if(adotable1.RecordCount>0) thenrn beginrn x:=application.MessageBox(pchar('删除记录:'+trim(edit1.text)+char(13)+char(13)+'是否确定?'),'系统提示',4+32);rn if(x=6)then adotable1.Delete;rn end;rnend;rnrnrnrnprocedure TForm6.ToolButton5Click(Sender: TObject);rnbeginrnadotable1.Close;rnadotable1.open;rnend;rnrnprocedure TForm6.ToolButton6Click(Sender: TObject);rnbeginrnform6.Close;rnform3.show;rnend;rnrnfunction TForm6.ptest():string;rnvarrns1,s2,s3,s4,s5,s6,xerr:string;rnx:double;rnx1,x2:integer;rnbeginrn //数据验证,错误信息存放在xerr中rn xerr:='';rn //判断数值型数据是否正确rn x:=0;rn s1:=trim(edit1.text);rn s2:=trim(edit2.text);rn s3:=trim(edit3.text);rn s4:=trim(edit4.text);rn s5:=trim(edit5.Text);rn s6:=trim(edit6.Text);rn beginrn //验证产品编码是否唯一rn adoquery1.close;rn adoquery1.sql.text:='select 1 from room where roomid=p1';rn adoquery1.Parameters.ParamByName('p1').Value:=s1;rn adoquery1.Open;rn if adoquery1.RecordCount>0 then xerr:=xerr+char(13)+'房间号码重复!';rn end;rn if (s1='') then xerr:=xerr+char(13)+'房间号码不能为空!';rn if (s2='') then xerr:=xerr+char(13)+'房间类型不能为空!';rn if (s6='') then xerr:=xerr+char(13)+'房间价格不能为空!';rn result:=xerr;rnend;rn
List index out of bounds
我用TList来保存临时用户列表。这边对列表循环查找,另一个函数已经删除了一个项目了。这样就会出现越界提示。rn用什么方法可以?rnrn如果用互斥的话,会不会影响到程序的性能?
出现list index out of bounds(2);
在执行数据修改时,出现这个错误,我原来都好的,代码没改,可是今天却出现这个错误,别的库修改时没这个错,代码一样呀!这是什么现象?是ado的问题还是D6的问题!
为什么出现list index out of brounts(-1)?
一个奇怪的问题?rn我发现我的delphi3。0在运行时如果执行下面一段代码打开一个文件rngridsj是一个stringgridrnprocedure TForm1.btreadClick(Sender: TObject);rnvarrn openfilename:string;rn rdstr:string;rn f :textfile;rn i,j,temp:integer;rnbeginrn if opendialog.Execute thenrn beginrn openfilename:=opendialog.FileName;rn if fileexists(openfilename) thenrn begin 读取预处理rn assignfile(f,openfilename);rn reset(f);rn 以下为读取段rn readln(f,rdstr);rn readln(f,zbgs,qsdx,qsdy,qsdfwjjd,qsdfwjhd);rn edbt.Text:=rdstr;rn edqsdhzbx.Text:=formatfloat('0.0000',qsdx);rn edqsdzzby.Text:=formatfloat('0.0000',qsdy);rn edqsdfwjjd.Text:=formatfloat('0.0000',qsdfwjjd);rn edqsdfwjhd.Text:=formatfloat('0.000000',qsdfwjhd);rn for i:=1 to zbgs dorn beginrn readln(f,zbsj[1,i],zbsj[2,i]);rn end;rn closefile(f);rn temp:=gridsj.RowCount-1;rn gridsj.RowCount:=zbgs+1;rn for i:=temp+1 to zbgs do gridsj.Cells[0,i]:='J'+inttostr(i);rn for i:=1 to 2 dorn for j:=1 to zbgs do gridsj.Cells[i,j]:=formatfloat('0.0000',zbsj[i,j]);rn endrn elsern Application.MessageBox('文件找不到!','错误!',mb_ok+mb_defbutton1)rn end;rnend;rnrn然后关闭返回编辑时,如果不在代码窗口中进行改动,则再次运行时就报rnlist index out of brounts(-1)rninvalid pointer operationrn如果退出delphi就报rnexception einvalidpointer in module vcl30.dpl at 000038eern如果不退出就无法再运行该程序。rn用看进程的工具可以看到这个程序仍然驻留在内存。请问这是怎么回事?
怎么老是出现“list index out of bounds”?
procedure TForm1.Button1Click(Sender: TObject);rnvar i:integer;rnbeginrnfor i:=0 TO listbox1.items.count-1 dorn if listbox1.items[i]=edit1.text thenrn beginrn listbox1.items.Delete(i);rn endrnend;
出现list index out of bounds(0)?
运用Socket编写了一个客户端,不过只能连上和接收服务器的信息,不知道为何不能发送信息,而且在退出时出现这个错误list index out of bounds(0),究竟该怎么改啊?查了很多资料都不知道该如何下手,请各位帮忙看看rnunit Client;rnrninterfacernrnusesrn Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,rn Dialogs, ScktComp, StdCtrls, ComCtrls, Menus;rnrntypern TfrmClient = class(TForm)rn MainMenu1: TMainMenu;rn Cennect: TMenuItem;rn DisConnect: TMenuItem;rn About: TMenuItem;rn Exit: TMenuItem;rn SSent: TMemo;rn CSent: TMemo;rn btSent: TButton;rn StatusBar: TStatusBar;rn SesInfor: TGroupBox;rn Label1: TLabel;rn edIP: TEdit;rn Label2: TLabel;rn EdPort: TEdit;rn ClientSocket: TClientSocket;rn procedure CennectClick(Sender: TObject);rn procedure ClientSocketConnect(Sender: TObject;rn Socket: TCustomWinSocket);rn procedure CSentKeyDown(Sender: TObject; var Key: Word;rn Shift: TShiftState);rn procedure ClientSocketRead(Sender: TObject; Socket: TCustomWinSocket);rn procedure ClientSocketDisconnect(Sender: TObject;rn Socket: TCustomWinSocket);rn procedure btSentClick(Sender: TObject);rn procedure AboutClick(Sender: TObject);rn procedure ExitClick(Sender: TObject);rn privatern Private declarations rn publicrn Public declarations rn end;rnrnvarrn frmClient: TfrmClient;rn ServerSocket:TServerSocket;rnrnimplementationrnuses unit2;rnrn$R *.dfmrnrn//激活客户端rnprocedure TfrmClient.CennectClick(Sender: TObject);rnbeginrn ClientSocket.Address:=edIP.Text; //设定IPrn ClientSocket.Port:=StrToInt(edPort.Text); //设定端口rn ClientSocket.Active:=true;rnend;rnrn//建立连接rnprocedure TfrmClient.ClientSocketConnect(Sender: TObject;rn Socket: TCustomWinSocket);rnbeginrn Statusbar.Panels.Items[0].Text:='成功连接到服务器'+ServerSocket.Name;rnend;rnrn//在对话框按回车发送信息rnprocedure TfrmClient.CSentKeyDown(Sender: TObject; var Key: Word;rn Shift: TShiftState);rnbeginrn ClientSocket.Socket.SendText(CSent.Lines[CSent.Lines.Count ]);rnend;rn//按发送按钮发送信息rnprocedure TfrmClient.btSentClick(Sender: TObject);rnbeginrn ClientSocket.Socket.SendText(CSent.Lines[CSent.Lines.Count ]);rnend;rnrn//获取服务器的信息以及显示客户端本身发送的信息rnprocedure TfrmClient.ClientSocketRead(Sender: TObject;rn Socket: TCustomWinSocket);rnbeginrn SSent.Lines.Add(Socket.ReceiveText);rnend;rnrn//断开连接rnprocedure TfrmClient.ClientSocketDisconnect(Sender: TObject;rn Socket: TCustomWinSocket);rnbeginrn ClientSocket.Active:=false;rn Statusbar.Panels.Items[0].Text:='关闭与服务器的连接';rn CSent.Lines.Clear;rnend;rnrnrn//获取软件信息rnprocedure TfrmClient.AboutClick(Sender: TObject);rnbeginrn Form2.Show; rnend;rnrn//退出程序rnprocedure TfrmClient.ExitClick(Sender: TObject);rnbeginrn if ClientSocket.Active thenrn ClientSocket.Close;rn frmClient.Close;rnend;rnrnend.rn
求助! 出现 “list index out of bounds(0)”
我想将文本文件导入到sql表里。可出现“list index out of bounds(0)的错误。rn 不知错在哪里,特此向各位求教!请指正! 谢谢!rn rn 已建立的txt内容如下:名为zgxxb11.txtrn a00002~wuhaiqing~1~1981-08-03~2003-04-05~rn a00003~zhangling~0~1979-10-23~2003-02-01~rn a00004~mahuili~0~1981-03-04~2002-03-23~rnrn 已创建了一张表zgxxb11如下:rn create table zgxxb11rn ( rn zgxx_dm char(6) not null,rn zgxx_xh numeric(10) identity,rn zgxx_xm varchar(10) not null,rn zgxx_xb char(1) not null,rn zgxx_csrq datetime not null,rn zgxx_lrrq datetime not null)rn rn rn代码如下:rn void __fastcall TForm1::Button1Click(TObject *Sender)rnrn TStringList * pList = new TStringList;rn pList -> LoadFromFile("c:\\mtemp\\zgxxb11.txt");rn for (int i=0;iCount;i++)rn rn String Record = pList->Strings[i];String RecordSet[5];rn int rs_pos=0;rn int start_pos=0;rnrn for (int j=0;j<5;j++)rn RecordSet[j]="";rn Record = Record.Trim();rn if (Record.IsEmpty())rn rn return ;rn rnrn for (int j=1;jADOQuery1->Close();rn Form1->ADOQuery1->SQL->Clear();rn Form1->ADOQuery1->SQL->Add("insert into zgxxb11");rn Form1->ADOQuery1->SQL->rn Add("zgxx_dm,zgxx_xm,zgxx_xb,zgxx_csrq,zgxx_lrrq");rn Form1->ADOQuery1->SQL->Add("values(:p1,:p2,:p3,:p4,:p5)");rnrnrn for (int i=0;i<5;i++)rn rn rn Form1->ADOQuery1->Fields->Fields[i]->AsString=RecordSet[i];rn rnrn Form1->ADOQuery1->ExecSQL();rn //end of forrn delete pList;rnrnrnrn//----------------------------rnrn
List index out of bounds(0)错误;
在多层中出现以下错误,一般而言是因为什么造成的?rnProject Client.exe raised exception class EOleException with message'List index out of bounds(0)'.process stopped.use Step or Run to coutinue.rn就是下边的事件产生的;rnDataModule1.UpDateClientDataSet.ApplyUpdates(1);rn为什么呢?有没有做过的,请帮助
adoquery 'List index out of bounds (0)的错误
以下是我的代码:rnprocedure TForm1.bsSkinButton2Click(Sender: TObject);rnvarrnSQL2 :string;rnbeginrn SQL2:='insert into tfjygh(l_ztbh,vc_zqdm,l_sclb,d_rq,en_sl,en_lx)'rn +' values(:ztbh,:zqdm,:sclb,:dxsj,:dxsl,:dxje)';rn adoQuery.parameters[0].Value:=strtoint(ztbh.EditText);rn adoQuery.parameters[1].Value:=zqdm.EditText;rn adoQuery.parameters[2].Value:=strtoint(sclb.EditText);rn adoQuery.parameters[3].Value:=trunc(dxsj.Date);rn adoQuery.parameters[4].Value:=strtoint(dxsl.EditText);rn adoQuery.parameters[5].Value:=strtoint(dxje.EditText);rn with ADOQuery1 dorn beginrn Close;rn SQL.Clear;rn SQL.Add(SQL2);rn execSQL;rn end;rnrnend;rnrn以下是我的错误:rn---------------------------rnProject1rn---------------------------rnList index out of bounds (0)rn---------------------------rn确定 rn---------------------------rnrn新手着急啊 在线等 谢谢先!
关于错误list index out of bound(1)
我是要在DBGrid1里选取几行,然后在数据库中删除相应数据,并更新DBGrid1,其中DBGrid1的DataSource属性赋值为DataSource1,Query1的SQL属性赋值为select * from bookshop其代码如下:rnbeginrn if DBGrid1.SelectedRows.Count>0 thenrn beginrn with DBGrid1.DataSource.DataSet dorn for i:=0 to DBGrid1.SelectedRows.Count-1 dorn beginrn Query1.Close;rn Query1.SQL.Clear;rn GotoBookmark(pointer(DBGrid1.SelectedRows.Items[i]));rn id:=Fields[0].AsString;rn MessageDlg(id, mtInformation, [mbOK], 0);rn Query1.SQL.Text:= 'delete from bookshop where 书店名称="id"';rn Query1.ExecSQL;rn end;rn Query1.Open;rn end;rn可是每次执行到GotoBookmark(pointer(DBGrid1.SelectedRows.Items[i]));时都提示list index out of bound(1),还请各位大虾指点一二!!小弟在此谢谢了!
List index out of bounds (1)是什么错误
前几天想做一个智能查询的东西,就是在编辑框里输入内容,马上模糊检索数据库中的相关记录,并在下面提示出来,我的思路是用一个edit和一个listbox来实现,edit设置onchange事件,即时的由edit.text的内容搜索数据库,然后将结果赋给listbox的items,并设置listbox可见,listbox的click事件则将选择的内容赋到edit中。编译没有问题,但是在实际运行时,当我在listbox中选择一项时,就弹出List index out of bounds的错误,请问这是什么原因啊,是不是需要设置什么属性?SOS!
list index out of bounds(-1)?错误原因?
前面有这样的语句listbox1.ItemIndex:=0;rn为什么会出现这样的错误?rnlist index out of bounds(-1)?
Mybatis批量插入index out of range错误(较偏的错误)
批量插入,错误是何,拒绝转载!前言原因改进 d 前言 往往我们看到网上关于各类关于批量插入报这种错误的文章都是传入的集合为null,或者是参数获取不对等等,但是在开发的时候同事遇到了这种类型的错误,我一直以为是网上那些博客那些原因造成的,于是,两只眼睛一直盯着代码看来许久都没有找出什么问题。那是什么问题呢? 原因 是由于项目中用的是sharding-jdbc来进行数据库连接,而sharding-j...
急急,数据库操作出现list index out of bounds(0) 错误
用DBExpress连接DB2数据库。使用TSQLDataSet执行存储过程的时候(动态创建存储过程参数),一直报 list index out of bounds(0)错。rn静态下来存储过程,自动产生参数后,可以执行。rn存储过程:rnCREATE PROCEDURE proc_NewSave_Sys (v_uniqueguid_2 VARCHAR(36), rn v_uniqueid_3 VARCHAR(32), rn v_agent_4 VARCHAR(16), rn v_callid_5 VARCHAR(24), rn v_calledid_6 VARCHAR(24), rn v_extention_7 VARCHAR(16), rn v_preid_8 VARCHAR(16), rn v_nextid_9 VARCHAR(16), rn v_starttime_10 VARCHAR(36), rn v_endtime_11 VARCHAR(36), rn v_howtime_12 INTEGER, rn v_acd_13 INTEGER, rn v_dins_14 INTEGER, rn v_inorout_15 SMALLINT, rn v_ifback_16 SMALLINT, rn v_backwhere_17 VARCHAR(30), rn v_backpath_18 VARCHAR(10), rn v_voicepath_19 VARCHAR(32), rn v_datapath_20 VARCHAR(32), rn v_files_21 VARCHAR(20), rn v_whereplace_22 VARCHAR(30), rn v_voicesize_23 INTEGER, rn v_datasize_24 INTEGER, rn v_restorepath_25 VARCHAR(64),rn v_columns_1 CHAR(50),rn v_columns_2 CHAR(50),rn v_columns_3 CHAR(50),rn v_columns_4 CHAR(50),rn v_columns_5 CHAR(50),rn v_columns_6 CHAR(50),rn v_columns_7 CHAR(50),rn v_columns_8 CHAR(50),rn v_columns_9 CHAR(50),rn v_columns_10 CHAR(50),rn OUT v_outvalue INTEGER)rn。。。。。rn。。。。。rn调用代码:rnrn SQLDataSet1.CommandType:= ctStoredProc;rn SQLDataSet1.CommandText:= Format('%s.proc_NewSave_Sys',[trim(edtschema.text)]);rn SQLDataSet1.close;rn SQLDataSet1.Params.Clear;rn //FADOStoredProc.Params.CreateParam(ftInteger,'v_return',ptResult).AsInteger:= -1;rn SQLDataSet1.Params.CreateParam(ftString,'v_uniqueguid_2',ptInput).AsString:= 'DVS+'+guid+'-3001';rn SQLDataSet1.Params.CreateParam(ftString,'V_uniqueid_3',ptInput).AsString:= guid;rn SQLDataSet1.Params.CreateParam(ftString,'V_agent_4',ptInput).AsString:= '3001';rn SQLDataSet1.Params.CreateParam(ftString,'V_callid_5',ptInput).AsString:= '';rn SQLDataSet1.Params.CreateParam(ftString,'V_calledid_6',ptInput).AsString:= '';rn SQLDataSet1.Params.CreateParam(ftString,'V_extention_7',ptInput).AsString:= '3001';rn SQLDataSet1.Params.CreateParam(ftString,'V_preid_8',ptInput).AsString:= '';rn SQLDataSet1.Params.CreateParam(ftString,'V_nextid_9',ptInput).AsString:= '';rnrn begintime:= FormatDateTime('yyyy-mm-dd hh:nn:ss',now);rn endtime:= FormatDateTime('yyyy-mm-dd hh:nn:ss',now + StrToFloat(Trim(EdtHowTime.Text))/24/60/60);rn SQLDataSet1.Params.CreateParam(ftString,'V_starttime_10',ptInput).AsString:= begintime;rn SQLDataSet1.Params.CreateParam(ftString,'V_endtime_11',ptInput).AsString:= endtime;rn SQLDataSet1.Params.CreateParam(ftInteger,'V_howtime_12',ptInput).AsInteger:= StrToInt(Trim(EdtHowTime.Text));rn SQLDataSet1.Params.CreateParam(ftInteger,'V_acd_13',ptInput).AsInteger:= 0;rn SQLDataSet1.Params.CreateParam(ftInteger,'V_dins_14',ptInput).AsInteger:= 0;rn SQLDataSet1.Params.CreateParam(ftSmallint,'V_inorout_15',ptInput).AsInteger:= 0;rn SQLDataSet1.Params.CreateParam(ftSmallint,'V_ifback_16',ptInput).AsInteger:= 0;rn SQLDataSet1.Params.CreateParam(ftString,'V_backwhere_17',ptInput).AsString:= '';rn SQLDataSet1.Params.CreateParam(ftString,'V_backpath_18',ptInput).AsString:= '';rn SQLDataSet1.Params.CreateParam(ftString,'V_voicepath_19',ptInput).AsString:= '';rn SQLDataSet1.Params.CreateParam(ftString,'V_datapath_20',ptInput).AsString:= destpath;rn SQLDataSet1.Params.CreateParam(ftString,'V_files_21',ptInput).AsString:= filename+ '3001';rn SQLDataSet1.Params.CreateParam(ftString,'V_whereplace_22',ptInput).AsString:= '';rn SQLDataSet1.Params.CreateParam(ftInteger,'V_voicesize_23',ptInput).AsInteger:= 0;rn SQLDataSet1.Params.CreateParam(ftInteger,'V-datasize_24',ptInput).AsInteger:= 1000;rn SQLDataSet1.Params.CreateParam(ftString,'V_restorepath_25',ptInput).AsString:= '';rn SQLDataSet1.Params.CreateParam(ftFixedChar,'V_columns_1',ptInput).AsString:= '';rn SQLDataSet1.Params.CreateParam(ftFixedChar,'V_columns_2',ptInput).AsString:= '';rn SQLDataSet1.Params.CreateParam(ftFixedChar,'V-columns_3',ptInput).AsString:= '';rn SQLDataSet1.Params.CreateParam(ftFixedChar,'V_columns_4',ptInput).AsString:= '';rn SQLDataSet1.Params.CreateParam(ftFixedChar,'V_columns_5',ptInput).AsString:= '';rn SQLDataSet1.Params.CreateParam(ftFixedChar,'V_columns_6',ptInput).AsString:= '';rn SQLDataSet1.Params.CreateParam(ftFixedChar,'V_columns_7',ptInput).AsString:= '';rn SQLDataSet1.Params.CreateParam(ftFixedChar,'V_columns_8',ptInput).AsString:= '';rn SQLDataSet1.Params.CreateParam(ftFixedChar,'V_columns_9',ptInput).AsString:= '';rn SQLDataSet1.Params.CreateParam(ftFixedChar,'V_columns_10',ptInput).AsString:= '';rn SQLDataSet1.Params.CreateParam(ftInteger,'V_outvalue',ptOutput).AsInteger:= outvalue;rn Memo1.Lines.Add(IntToStr( SQLDataSet1.Params.Count));rn SQLDataSet1.ExecSQL();
相关热词 c++和c#哪个就业率高 c# 批量动态创建控件 c# 模块和程序集的区别 c# gmap 截图 c# 验证码图片生成类 c# 再次尝试 连接失败 c#开发编写规范 c# 压缩图片好麻烦 c#计算数组中的平均值 c#获取路由参数