Showing posts with label idea. Show all posts
Showing posts with label idea. Show all posts

Saturday, March 31, 2012

There is no row at position 0?

I encountered an error: There is no row at position 0.

I have no idea what went wrong. Kindly advise. Thank you!

=====================================================

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

If Not IsPostBack Then
getDetails()
End If

Dim confirmMsg As String

' On reolad
If Page.IsPostBack Then
' Set Message to Notify User
confirmMsg = "The event has been updated successfully."
'display msg
lblConfirm.Text = confirmMsg
End If

End Sub

Sub getDetails()

Dim sql1 As OleDbDataAdapter
Dim objCommand As OleDbCommand
Dim strSQLQuery As String
Dim oledbconnection1 As OleDbConnection

Dim passedID As String
passedID = Request.QueryString("EventID")

strSQLQuery = "SELECT * FROM Event WHERE EventID= '" & passedID & "'"

oledbconnection1 = New OleDbConnection(Application("connectionStr"))

objCommand = New OleDbCommand(strSQLQuery, oledbconnection1)
sql1 = New OleDbDataAdapter(objCommand)

Dim dset1 As New DataSet
sql1.Fill(dset1, "Event")

txtTitle.Text &= " " & dset1.Tables("Event").Rows(0).Item("EventTitle")

oledbconnection1.Open()
objCommand.ExecuteNonQuery()
oledbconnection1.Close()

End SubHi,

it would be nice if you also gave the relevant place where the error occured. But the times that I encountered this error message just ment exactly what it states: there is no row --> there are 0 rows returned by your query or the dataset didn't get filled.

Grz, Kris.
Debug getDetails...
-----------

Sub getDetails()

Dim sql1 As OleDbDataAdapter
Dim objCommand As OleDbCommand
Dim strSQLQuery As String
Dim oledbconnection1 As OleDbConnection
Debug your method...

Dim passedID As String
passedID = Request.QueryString("EventID")

'!!! Evaluate passedID. What does it contain? If its a valid value then continue !!!
strSQLQuery = "SELECT * FROM Event WHERE EventID= '" & passedID & "'"

'!!! Now evaluate strSqlQuery. What does it contain?? If valid continue !!!
oledbconnection1 = New OleDbConnection(Application("connectionStr"))

objCommand = New OleDbCommand(strSQLQuery, oledbconnection1)
sql1 = New OleDbDataAdapter(objCommand)

Dim dset1 As New DataSet
sql1.Fill(dset1, "Event")

txtTitle.Text &= " " & dset1.Tables("Event").Rows(0).Item("EventTitle")

End Sub

As long as it all passed ok. That should return a resultset.

Saying that I,ve not checked it syntax wise but its more fluid.

Wednesday, March 28, 2012

This connections gonna kill me

This is a long one. (Question that is) an I have been working on this problem for a week now and still have no idea. There are no systems/database people here to help.

I have used the following string to succesfully connect to my SQL Server
database :

"Provider=SQLOLEDB.1;
Password=mypassword;
Persist Security Info=True;
User ID=VSdotNET;
Initial Catalog=ITPSCustomers;
Data Source=DELL\VSdotNET"

The problem is that I do not want SQL Server authentication so I opened up
SQL Server, removed the login VBdotNET, added it again and changed the user
authentication to Windows. I then changed the connection string to :

"Provider=SQLOLEDB.1;
Integrated Security=SSPI;
Persist Security Info=False;
Initial Catalog=ITPSCustomers;
Data Source=DELL\VSdotNET"

DELL\VSdotNET is a Login and has been given permission to access the
database ITPSCustomers.

Within the Database node for ITPSCustomers database DELL\VSdotNET has been
added as a user and has been given all permisions to the tables and views
within the database.

When I now run my web page I get the errors :

System.Data.OleDb.OleDbException: Cannot open database requested in login
'ITPSCustomers'. Login fails.
at System.Data.OleDb.OleDbConnection.ProcessResults(Int32 hr)
at System.Data.OleDb.OleDbConnection.InitializeProvider()
at System.Data.OleDb.OleDbConnection.Open()
at DreamweaverCtrls.DataSet.DoInit() System.Exception:
The DefaultView was requested but no tables yet exist.
at DreamweaverCtrls.DataSet.get_DefaultView()

Can anyone help ?two things:

You should be using the SqlClient Namespace for all things related to data since you're using SQL Server (it's much faster)
Try this connection when using a SqlConnection

"Data Source=DELL\VSdotNET;
Trusted_Connection=True;
Initial Catalog=ITPSCustomers"

Hope that helps :)
Well the question is when you switched to windows authentication did you add the user unders security=>users in enterprise manager. Under the general tab beside name you get a browse button to pick a windows login to add and then you specify what database it can access under the database access tab. The SqlClient namespace is better for sql server (or msde) but it is unlikely to be the cause of the problem.

Tuesday, March 13, 2012

Thread was being aborted

Any Idea why we get this error, its happening in only one page and that too
first time user visits that page,in the below "GetData" is a method which
gets the data from SQL Server, but some times it is taking time to get data
and throwing this error i think it has to throw "Timed Out" instead of this
"Thread Abort" error. any idea why we get this error?
Exception Type: System.Threading.ThreadAbortException
ExceptionState: System.Web.HttpApplication+CancelModuleException
Message: Thread was being aborted.
TargetSite: System.Data.DataSet GetData(RPID,
System.Data.SqlClient.SqlCommand)Unless you post the full code around where the error happens, then I can
only guess. One common cause for this error is that you have a
Response.Redirect statement enclosed within a try...catch

--
[note: if this post answers your question, you can mark it as an answer
using the web-based newsreader functions]
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com

"xsluser" wrote:

> Any Idea why we get this error, its happening in only one page and that too
> first time user visits that page,in the below "GetData" is a method which
> gets the data from SQL Server, but some times it is taking time to get data
> and throwing this error i think it has to throw "Timed Out" instead of this
> "Thread Abort" error. any idea why we get this error?
> Exception Type: System.Threading.ThreadAbortException
> ExceptionState: System.Web.HttpApplication+CancelModuleException
> Message: Thread was being aborted.
> TargetSite: System.Data.DataSet GetData(RPID,
> System.Data.SqlClient.SqlCommand)
By default SQL Command has 30 second to finish.
If it did not finish then it's aborted.

Look at Command.CommandTimeout value and increase it.

George.

"xsluser" <xsluser@.discussions.microsoft.com> wrote in message news:F2E4E54F-7A47-47CE-BDC9-8FBDA9A9BD3F@.microsoft.com...
Any Idea why we get this error, its happening in only one page and that too
first time user visits that page,in the below "GetData" is a method which
gets the data from SQL Server, but some times it is taking time to get data
and throwing this error i think it has to throw "Timed Out" instead of this
"Thread Abort" error. any idea why we get this error?
Exception Type: System.Threading.ThreadAbortException
ExceptionState: System.Web.HttpApplication+CancelModuleException
Message: Thread was being aborted.
TargetSite: System.Data.DataSet GetData(RPID,
System.Data.SqlClient.SqlCommand)

Thread was being aborted

Any Idea why we get this error, its happening in only one page and that too
first time user visits that page,in the below "GetData" is a method which
gets the data from SQL Server, but some times it is taking time to get data
and throwing this error i think it has to throw "Timed Out" instead of this
"Thread Abort" error. any idea why we get this error?
Exception Type: System.Threading.ThreadAbortException
ExceptionState: System.Web.HttpApplication+CancelModuleException
Message: Thread was being aborted.
TargetSite: System.Data.DataSet GetData(RPID,
System.Data.SqlClient.SqlCommand)Unless you post the full code around where the error happens, then I can
only guess. One common cause for this error is that you have a
Response.Redirect statement enclosed within a try...catch
[note: if this post answers your question, you can mark it as an answer
using the web-based newsreader functions]
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"xsluser" wrote:

> Any Idea why we get this error, its happening in only one page and that to
o
> first time user visits that page,in the below "GetData" is a method which
> gets the data from SQL Server, but some times it is taking time to get dat
a
> and throwing this error i think it has to throw "Timed Out" instead of thi
s
> "Thread Abort" error. any idea why we get this error?
> Exception Type: System.Threading.ThreadAbortException
> ExceptionState: System.Web.HttpApplication+CancelModuleException
> Message: Thread was being aborted.
> TargetSite: System.Data.DataSet GetData(RPID,
> System.Data.SqlClient.SqlCommand)
By default SQL Command has 30 second to finish.
If it did not finish then it's aborted.
Look at Command.CommandTimeout value and increase it.
George.
"xsluser" <xsluser@.discussions.microsoft.com> wrote in message news:F2E4E54F
-7A47-47CE-BDC9-8FBDA9A9BD3F@.microsoft.com...
Any Idea why we get this error, its happening in only one page and that too
first time user visits that page,in the below "GetData" is a method which
gets the data from SQL Server, but some times it is taking time to get data
and throwing this error i think it has to throw "Timed Out" instead of this
"Thread Abort" error. any idea why we get this error?
Exception Type: System.Threading.ThreadAbortException
ExceptionState: System.Web.HttpApplication+CancelModuleException
Message: Thread was being aborted.
TargetSite: System.Data.DataSet GetData(RPID,
System.Data.SqlClient.SqlCommand)