I am working on QSWAT. i run the model but when i am using Import files to Database SWAT output file, it is showing Error "There is no row at position 0". I am not getting why this error is coming?? Can any one please suggests me how to resolve this error ??
Thanks in Advance
Nadege Yoni
unread,
May 24, 2021, 9:57:50 PM5/24/21
to SWAT-user
Dear sir,
I am facing a similar challenge and I would be grateful to know how you were able to solve this issue.
Looking forward to read from you soon.
Kindest regards
jens
unread,
May 25, 2021, 4:44:23 PM5/25/21
to SWAT-user
Prior to selecting "Write SWAT Input Tables" did you complete "Write Input Tables - Weather Stations"?
Benjamin Wullobayi Dekongmen
unread,
May 26, 2021, 4:00:53 AM5/26/21
to SWAT-user
Dear all,
I am facing the same issue. I have gone through all my data files to check, whether there was any file with a wrong name.
ER0016 | There is no row at position 0
Lỗi xuất hiện khi F12 sửa chứng từ theo form, Sửa lỗi 1 trong các cách sau
- do ngày chứng từ có giờ, kiểm tra và xử lý xóa giờ
- Vào danh mục các loại chưng tứ, sửa:Có xuất kho : F & kiểu chứng từ : HD
- hoặc kiểm tra 1 số trường khác như loại chứng từ số chứng từ ,ngày chứng từ,ID_CHUNGTU,GUID,ID_NGHIEPVU cũng có thể ảnh hưởng
- Lỗi TKCO chưa khai báo trong ID12 ?
Im trying to convert a hobby project from vb6 [word templates / Access Database] to Visual Basic .net in Visual Studio 2019
Code:
Private Sub SelectTour[TourID As Integer, ClientID As Integer]
Access.AddParam["@TourID", TourID]
'Access.AddParam["@TourID", FrmToursMain.TourID.Text]
'Access.AddParam["@ClientID", DataGridView1.Item[0, e.RowIndex].Value]
Access.AddParam["@ClientID", ClientID]
Access.ExecQuery["SELECT TourData.DepositDate, TourData.FileNumber, TourData.Insurance, [TourData.Notes], TourData.RoomNumber, TourData.CabinGrade, TourData.RoomType, TourData.CabinType, TourData.RoomWithID, [TourData.Visa], TourData.GetTogether, TourData.FlightData, TourData.FlightClass, TourData.ReferredBy, TourData.RecordUpdated, Clients.PassportExpiry, Clients.Birthdate, Clients.AirPoints, Clients.QFPoints, Clients.EKPoints, [TourData.Booking] FROM Clients RIGHT JOIN TourData ON Clients.ClientID = TourData.ClientID WHERE [[[TourData.ClientID]= @ClientID] AND [[TourData.TourID]= @TourID]]"]
' commented out error checking to throw error 'If NoErrors[True] = False OrElse Access.RecordCount < 1 Then Exit Sub
'error line Dim r As DataRow = Access.DBDT.Rows[0]
FileNumberTextBox.Text = r["FileNumber"].ToString
TourBooking.Text = r["Booking"].ToString
InsuranceTextBox.Text = r["Insurance"].ToString
etcMy skills with vb are mediocre at best, but Im trying to wrap my head around [potentially an SQL issue] generating an error:
System.IndexOutOfRangeException: 'There is no row at position 0.' This occurs at :
Code:
Dim r As DataRow = Access.DBDT.Rows[0]
The error suggests to me that there is no row being returned [as access.recordcount = 0] I know the code works, as it works elsewhere [all be it with different queries]. I also know the SQL works, as I can run it in the Access Query designer and it returns the one row as expected
Ive even tried minimizing the SQL to simplify it hard coding record ID's and it still throws that error
Is there an issue that Im not seeing with reserved words or ??
For the record, the access class is this code:
Code:
Imports System.Data.OleDb Public Class DBControl
' Conn
Private DBCon As New OleDbConnection[My.Settings.TravelConnectionString]
' DB Command
Private DBCmd As OleDbCommand
' DB Data
Public DBDA As OleDbDataAdapter
Public DBDT As DataTable
' Query params
Public Params As New List[Of OleDbParameter]
' Query Stats
Public RecordCount As Integer
Public Exception As String
Public Sub ExecQuery[Query As String]
'Reset Query
RecordCount = 0
Exception = ""
Try
'Open conn
DBCon.Open[]
'Creat DB command
DBCmd = New OleDbCommand[Query, DBCon]
'Load Params
Params.ForEach[Sub[p] DBCmd.Parameters.Add[p]]
' Clear params
Params.Clear[]
'Execute cmd
DBDT = New DataTable
DBDA = New OleDbDataAdapter[DBCmd]
RecordCount = DBDA.Fill[DBDT]
Catch ex As Exception
Exception = ex.Message
End Try
'Close conn
If DBCon.State = ConnectionState.Open Then DBCon.Close[]
End Sub
'Include Query & Comm Params
Public Sub AddParam[Name As String, Value As Object]
Dim newParam As New OleDbParameter[Name, Value]
Params.Add[newParam]
End Sub
End ClassLast edited by SpookyAwol; Dec 6th, 2020 at 06:24 PM.
- Dec 6th, 2020, 05:50 PM
Re: There is no row at position 0
I'm not familiar with ExecQuery or what data-type the Access object is.
Try doing it a bit differently, take a look at this example:
Code:
Dim commandString As String = " > SELECT > TourData.DepositDate, > TourData.FileNumber, > TourData.Insurance, > [TourData.Notes], > TourData.RoomNumber, > TourData.CabinGrade, > TourData.RoomType, > TourData.CabinType, > TourData.RoomWithID, > [TourData.Visa], > TourData.GetTogether, > TourData.FlightData, > TourData.FlightClass, > TourData.ReferredBy, > TourData.RecordUpdated, > Clients.PassportExpiry, > Clients.Birthdate, > Clients.AirPoints, > Clients.QFPoints, > Clients.EKPoints, > [TourData.Booking] > FROM > Clients > RIGHT JOIN TourData ON > Clients.ClientID = TourData.ClientID > WHERE > TourData.ClientID] = @ClientID > AND TourData.TourID = @TourID;" Dim con As OleDbConnection > Try > con = New OleDbConnection["My Connection String Here"] Using cmd = New OleDbCommand[commandString, con] > cmd.Parameters.Add["@ClientID", OleDbType.Integer].Value = ClientID > cmd.Parameters.Add["@TourID", OleDbType.Integer].Value = TourID con.Open[] Dim reader = cmd.ExecuteReader[] > If [reader.Read[]] Then > Dim currentRow = reader[0] > ' do something with currentRow > End If con.Close[] > End Using > Catch ex As Exception > Console.WriteLine[ex.Message] > Finally > If con IsNot Nothing Then > If con.State = ConnectionState.Open Then > ' Close the connection if it was left open[exception thrown] > con.Close[] > End If > con.Dispose[] > End If > End Try
What I'm doing is:
- declaring my SQL command text in a separate variable and formatting it for readability
- creating a new connection
- creating a new command using the command text and connection
- parameterizing the query, specifying the parameter data-types
- calling ExecuteReader to return a DataReader object
- checking if there are rows by doing If [reader.Read[]] Then
- if there are, then I'm getting the current row [which would be the first]
- cleaning up the connection
Last edited by dday9; Dec 6th, 2020 at 11:02 PM.
- - Dec 6th, 2020, 06:21 PM Thread Starter Member-
Re: There is no row at position 0
What would it suggest is wrong if it doesnt go past msgbox["execute reading"] ? No errors, just doesnt complete the .read
Code:
Dim reader = cmd.ExecuteReader[] MsgBox["execute reading"] If [reader.Read[]] Then > MsgBox["reading"] Dim currentRow = reader[0] > ' do something with currentRow > FileNumberTextBox.Text = currentRow["FileNumber"].ToString > Else > MsgBox["not reading"] > End If
This is correct for returning the value to a form?
Code:
FileNumberTextBox.Text = currentRow["FileNumber"].ToString
- Dec 6th, 2020, 08:02 PM
Re: There is no row at position 0
There may be exceptions to this, but I have never known Access to really deal with named parameters as you have. My understanding is that you can give them whatever names you want, but Access will use them in the order that you supply them. You try to use ClientID first and TourID second, but you supply TourID first and ClientID second. Try reversing that first.