D
dbahooker
team
i'm having a tough time getting these data readers to work correctly
I'd just like to be able to centralize my GetDataReader functions; so i
can pass a simple SQL statement and be passed back a valid DataReader
object.
I've been slaving with this all day long. I've been trying 'new' and
not new and just slaving over this; im calling it an early day..
I'm pretty darn sure i've got my connection working; i know my SQL is
working correctly.
I can setup a command and it works just fine (executeNonQuery).
I just can't figure out what i'm doing wrong on this side.
It's like-- it keeps on complaining that i've already got a dataset by
the same name; shouldn't MARS make this easier??
-------------------------------------------------------------
System.Transactions Critical: 0 : <TraceRecord
xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord"
Severity="Critical"><TraceIdentifier>http://msdn.microsoft.com/TraceCodes/System/ActivityTracing/2004/07/Reliability/Exception/Unhandled</TraceIdentifier><Description>Unhandled
exception</Description><AppDomain>FileMon.vshost.exe</AppDomain><Exception><ExceptionType>System.NullReferenceException,
mscorlib, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089</ExceptionType><Message>Object
reference not set to an instance of an object.</Message><StackTrace>
at FileMon.basCatalog.Catalog() in C:\Documents and Settings\aarkem\My
Documents\Visual Studio
2005\Projects\FileMon8_20060501\FileMon_9\basCatalog.vb:line 28
at FileMon.frmMain.Button1_Click(Object sender, EventArgs e) in
C:\Documents and Settings\aarkem\My Documents\Visual Studio
2005\Projects\FileMon8_20060501\FileMon_9\frmMain.vb:line 19
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message&amp; m,
MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message&amp; m)
at System.Windows.Forms.ButtonBase.WndProc(Message&amp; m)
at System.Windows.Forms.Button.WndProc(Message&amp; m)
at
System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message&amp;
m)
at
System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message&amp;
m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd,
Int32 msg, IntPtr wparam, IntPtr lparam)
at
System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG&amp;
msg)
at
System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32
dwComponentID, Int32 reason, Int32 pvLoopData)
at
System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32
reason, ApplicationContext context)
at
System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32
reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at FileMon.frmMain.Main() in C:\Documents and Settings\aarkem\My
Documents\Visual Studio
2005\Projects\FileMon8_20060501\FileMon_9\frmMain.Designer.vb:line 2
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[]
args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence
assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext
executionContext, ContextCallback callback, Object state)
at
System.Threading.ThreadHelper.ThreadStart()</StackTrace><ExceptionString>System.NullReferenceException:
Object reference not set to an instance of an object.
at FileMon.basCatalog.Catalog() in C:\Documents and
Settings\aarkem\My Documents\Visual Studio
2005\Projects\FileMon8_20060501\FileMon_9\basCatalog.vb:line 28
at FileMon.frmMain.Button1_Click(Object sender, EventArgs e) in
C:\Documents and Settings\aarkem\My Documents\Visual Studio
2005\Projects\FileMon8_20060501\FileMon_9\frmMain.vb:line 19
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message&amp; m,
MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message&amp; m)
at System.Windows.Forms.ButtonBase.WndProc(Message&amp; m)
at System.Windows.Forms.Button.WndProc(Message&amp; m)
at
System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message&amp;
m)
at
System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message&amp;
m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd,
Int32 msg, IntPtr wparam, IntPtr lparam)
at
System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG&amp;
msg)
at
System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32
dwComponentID, Int32 reason, Int32 pvLoopData)
at
System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32
reason, ApplicationContext context)
at
System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32
reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at FileMon.frmMain.Main() in C:\Documents and Settings\aarkem\My
Documents\Visual Studio
2005\Projects\FileMon8_20060501\FileMon_9\frmMain.Designer.vb:line 2
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[]
args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence
assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext
executionContext, ContextCallback callback, Object state)
at
System.Threading.ThreadHelper.ThreadStart()</ExceptionString></Exception></TraceRecord>
-------------------------------
Public Sub Catalog()
TOTAL_FILEKEEP = 0
ROOTFOLDER_DINCLAUSE = DinClause("ROOTFOLDERID", "ROOTFOLDERS",
"ACTIVE=1")
Dim rootFolderID As Integer
Dim RootFolder As String
Dim DR As New System.Data.SqlClient.SqlDataReader
DR = Nothing
SetDataReader(DR, "EXEC spRootFoldersToCatalog")
While DR.Read
RootFolder = DR.GetValue(1).ToString
rootFolderID = CInt(DR.GetValue(0).ToString)
Call RootFolder_Catalog(RootFolder, rootFolderID)
End While
Files_Catalog()
End Sub
--------------------------------------------------------------------------------
Public Sub SetDataReader(ByRef thisDR As
System.Data.SqlClient.SqlDataReader, ByVal strSql As String)
frmMain.WriteStatus(strSql)
Dim cmd As New System.Data.SqlClient.SqlCommand
cmd.CommandText = strSql
cmd.Connection = cnnX
Try
thisDR = cmd.ExecuteReader
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
-----------------------------------------------
Public Sub RunSql(ByVal strSql As String)
Dim cmd As New System.Data.SqlClient.SqlCommand
frmMain.WriteStatus(strSql)
cmd.CommandText.Equals(strSql)
Try
cmd.ExecuteNonQuery()
Catch ex As Exception
frmMain.WriteStatus("SQL FAILED: " & strSql)
Stop
End Try
End Sub
---------------------------------------------
i'm having a tough time getting these data readers to work correctly
I'd just like to be able to centralize my GetDataReader functions; so i
can pass a simple SQL statement and be passed back a valid DataReader
object.
I've been slaving with this all day long. I've been trying 'new' and
not new and just slaving over this; im calling it an early day..
I'm pretty darn sure i've got my connection working; i know my SQL is
working correctly.
I can setup a command and it works just fine (executeNonQuery).
I just can't figure out what i'm doing wrong on this side.
It's like-- it keeps on complaining that i've already got a dataset by
the same name; shouldn't MARS make this easier??
-------------------------------------------------------------
System.Transactions Critical: 0 : <TraceRecord
xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord"
Severity="Critical"><TraceIdentifier>http://msdn.microsoft.com/TraceCodes/System/ActivityTracing/2004/07/Reliability/Exception/Unhandled</TraceIdentifier><Description>Unhandled
exception</Description><AppDomain>FileMon.vshost.exe</AppDomain><Exception><ExceptionType>System.NullReferenceException,
mscorlib, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089</ExceptionType><Message>Object
reference not set to an instance of an object.</Message><StackTrace>
at FileMon.basCatalog.Catalog() in C:\Documents and Settings\aarkem\My
Documents\Visual Studio
2005\Projects\FileMon8_20060501\FileMon_9\basCatalog.vb:line 28
at FileMon.frmMain.Button1_Click(Object sender, EventArgs e) in
C:\Documents and Settings\aarkem\My Documents\Visual Studio
2005\Projects\FileMon8_20060501\FileMon_9\frmMain.vb:line 19
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message&amp; m,
MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message&amp; m)
at System.Windows.Forms.ButtonBase.WndProc(Message&amp; m)
at System.Windows.Forms.Button.WndProc(Message&amp; m)
at
System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message&amp;
m)
at
System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message&amp;
m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd,
Int32 msg, IntPtr wparam, IntPtr lparam)
at
System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG&amp;
msg)
at
System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32
dwComponentID, Int32 reason, Int32 pvLoopData)
at
System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32
reason, ApplicationContext context)
at
System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32
reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at FileMon.frmMain.Main() in C:\Documents and Settings\aarkem\My
Documents\Visual Studio
2005\Projects\FileMon8_20060501\FileMon_9\frmMain.Designer.vb:line 2
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[]
args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence
assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext
executionContext, ContextCallback callback, Object state)
at
System.Threading.ThreadHelper.ThreadStart()</StackTrace><ExceptionString>System.NullReferenceException:
Object reference not set to an instance of an object.
at FileMon.basCatalog.Catalog() in C:\Documents and
Settings\aarkem\My Documents\Visual Studio
2005\Projects\FileMon8_20060501\FileMon_9\basCatalog.vb:line 28
at FileMon.frmMain.Button1_Click(Object sender, EventArgs e) in
C:\Documents and Settings\aarkem\My Documents\Visual Studio
2005\Projects\FileMon8_20060501\FileMon_9\frmMain.vb:line 19
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message&amp; m,
MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message&amp; m)
at System.Windows.Forms.ButtonBase.WndProc(Message&amp; m)
at System.Windows.Forms.Button.WndProc(Message&amp; m)
at
System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message&amp;
m)
at
System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message&amp;
m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd,
Int32 msg, IntPtr wparam, IntPtr lparam)
at
System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG&amp;
msg)
at
System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32
dwComponentID, Int32 reason, Int32 pvLoopData)
at
System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32
reason, ApplicationContext context)
at
System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32
reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at FileMon.frmMain.Main() in C:\Documents and Settings\aarkem\My
Documents\Visual Studio
2005\Projects\FileMon8_20060501\FileMon_9\frmMain.Designer.vb:line 2
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[]
args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence
assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext
executionContext, ContextCallback callback, Object state)
at
System.Threading.ThreadHelper.ThreadStart()</ExceptionString></Exception></TraceRecord>
-------------------------------
Public Sub Catalog()
TOTAL_FILEKEEP = 0
ROOTFOLDER_DINCLAUSE = DinClause("ROOTFOLDERID", "ROOTFOLDERS",
"ACTIVE=1")
Dim rootFolderID As Integer
Dim RootFolder As String
Dim DR As New System.Data.SqlClient.SqlDataReader
DR = Nothing
SetDataReader(DR, "EXEC spRootFoldersToCatalog")
While DR.Read
RootFolder = DR.GetValue(1).ToString
rootFolderID = CInt(DR.GetValue(0).ToString)
Call RootFolder_Catalog(RootFolder, rootFolderID)
End While
Files_Catalog()
End Sub
--------------------------------------------------------------------------------
Public Sub SetDataReader(ByRef thisDR As
System.Data.SqlClient.SqlDataReader, ByVal strSql As String)
frmMain.WriteStatus(strSql)
Dim cmd As New System.Data.SqlClient.SqlCommand
cmd.CommandText = strSql
cmd.Connection = cnnX
Try
thisDR = cmd.ExecuteReader
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
-----------------------------------------------
Public Sub RunSql(ByVal strSql As String)
Dim cmd As New System.Data.SqlClient.SqlCommand
frmMain.WriteStatus(strSql)
cmd.CommandText.Equals(strSql)
Try
cmd.ExecuteNonQuery()
Catch ex As Exception
frmMain.WriteStatus("SQL FAILED: " & strSql)
Stop
End Try
End Sub
---------------------------------------------