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 (executeNonQuer y).
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.Transact ions Critical: 0 : <TraceRecord
xmlns="http://schemas.microso ft.com/2004/10/E2ETraceEvent/TraceRecord"
Severity="Criti cal"><TraceIden tifier>http://msdn.microsoft. com/TraceCodes/System/ActivityTracing/2004/07/Reliability/Exception/Unhandled</TraceIdentifier ><Description>U nhandled
exception</Description><Ap pDomain>FileMon .vshost.exe</AppDomain><Exce ption><Exceptio nType>System.Nu llReferenceExce ption,
mscorlib, Version=2.0.0.0 , Culture=neutral ,
PublicKeyToken= b77a5c561934e08 9</ExceptionType>< Message>Object
reference not set to an instance of an object.</Message><StackT race>
at FileMon.basCata log.Catalog() in C:\Documents and Settings\aarkem \My
Documents\Visua l Studio
2005\Projects\F ileMon8_2006050 1\FileMon_9\bas Catalog.vb:line 28
at FileMon.frmMain .Button1_Click( Object sender, EventArgs e) in
C:\Documents and Settings\aarkem \My Documents\Visua l Studio
2005\Projects\F ileMon8_2006050 1\FileMon_9\frm Main.vb:line 19
at System.Windows. Forms.Control.O nClick(EventArg s e)
at System.Windows. Forms.Button.On Click(EventArgs e)
at System.Windows. Forms.Button.On MouseUp(MouseEv entArgs mevent)
at System.Windows. Forms.Control.W mMouseUp(Messag e&amp; m,
MouseButtons button, Int32 clicks)
at System.Windows. Forms.Control.W ndProc(Message& amp;amp; m)
at System.Windows. Forms.ButtonBas e.WndProc(Messa ge&amp; m)
at System.Windows. Forms.Button.Wn dProc(Message&a mp;amp; m)
at
System.Windows. Forms.Control.C ontrolNativeWin dow.OnMessage(M essage&amp;
m)
at
System.Windows. Forms.Control.C ontrolNativeWin dow.WndProc(Mes sage&amp;
m)
at System.Windows. Forms.NativeWin dow.DebuggableC allback(IntPtr hWnd,
Int32 msg, IntPtr wparam, IntPtr lparam)
at
System.Windows. Forms.UnsafeNat iveMethods.Disp atchMessageW(MS G&amp;
msg)
at
System.Windows. Forms.Applicati on.ComponentMan ager.System.Win dows.Forms.Unsa feNativeMethods .IMsoComponentM anager.FPushMes sageLoop(Int32
dwComponentID, Int32 reason, Int32 pvLoopData)
at
System.Windows. Forms.Applicati on.ThreadContex t.RunMessageLoo pInner(Int32
reason, ApplicationCont ext context)
at
System.Windows. Forms.Applicati on.ThreadContex t.RunMessageLoo p(Int32
reason, ApplicationCont ext context)
at System.Windows. Forms.Applicati on.Run(Form mainForm)
at FileMon.frmMain .Main() in C:\Documents and Settings\aarkem \My
Documents\Visua l Studio
2005\Projects\F ileMon8_2006050 1\FileMon_9\frm Main.Designer.v b:line 2
at System.AppDomai n.nExecuteAssem bly(Assembly assembly, String[]
args)
at System.AppDomai n.ExecuteAssemb ly(String assemblyFile, Evidence
assemblySecurit y, String[] args)
at Microsoft.Visua lStudio.Hosting Process.HostPro c.RunUsersAssem bly()
at System.Threadin g.ThreadHelper. ThreadStart_Con text(Object state)
at System.Threadin g.ExecutionCont ext.Run(Executi onContext
executionContex t, ContextCallback callback, Object state)
at
System.Threadin g.ThreadHelper. ThreadStart()</StackTrace><Exc eptionString>Sy stem.NullRefere nceException:
Object reference not set to an instance of an object.
at FileMon.basCata log.Catalog() in C:\Documents and
Settings\aarkem \My Documents\Visua l Studio
2005\Projects\F ileMon8_2006050 1\FileMon_9\bas Catalog.vb:line 28
at FileMon.frmMain .Button1_Click( Object sender, EventArgs e) in
C:\Documents and Settings\aarkem \My Documents\Visua l Studio
2005\Projects\F ileMon8_2006050 1\FileMon_9\frm Main.vb:line 19
at System.Windows. Forms.Control.O nClick(EventArg s e)
at System.Windows. Forms.Button.On Click(EventArgs e)
at System.Windows. Forms.Button.On MouseUp(MouseEv entArgs mevent)
at System.Windows. Forms.Control.W mMouseUp(Messag e&amp; m,
MouseButtons button, Int32 clicks)
at System.Windows. Forms.Control.W ndProc(Message& amp;amp; m)
at System.Windows. Forms.ButtonBas e.WndProc(Messa ge&amp; m)
at System.Windows. Forms.Button.Wn dProc(Message&a mp;amp; m)
at
System.Windows. Forms.Control.C ontrolNativeWin dow.OnMessage(M essage&amp;
m)
at
System.Windows. Forms.Control.C ontrolNativeWin dow.WndProc(Mes sage&amp;
m)
at System.Windows. Forms.NativeWin dow.DebuggableC allback(IntPtr hWnd,
Int32 msg, IntPtr wparam, IntPtr lparam)
at
System.Windows. Forms.UnsafeNat iveMethods.Disp atchMessageW(MS G&amp;
msg)
at
System.Windows. Forms.Applicati on.ComponentMan ager.System.Win dows.Forms.Unsa feNativeMethods .IMsoComponentM anager.FPushMes sageLoop(Int32
dwComponentID, Int32 reason, Int32 pvLoopData)
at
System.Windows. Forms.Applicati on.ThreadContex t.RunMessageLoo pInner(Int32
reason, ApplicationCont ext context)
at
System.Windows. Forms.Applicati on.ThreadContex t.RunMessageLoo p(Int32
reason, ApplicationCont ext context)
at System.Windows. Forms.Applicati on.Run(Form mainForm)
at FileMon.frmMain .Main() in C:\Documents and Settings\aarkem \My
Documents\Visua l Studio
2005\Projects\F ileMon8_2006050 1\FileMon_9\frm Main.Designer.v b:line 2
at System.AppDomai n.nExecuteAssem bly(Assembly assembly, String[]
args)
at System.AppDomai n.ExecuteAssemb ly(String assemblyFile, Evidence
assemblySecurit y, String[] args)
at Microsoft.Visua lStudio.Hosting Process.HostPro c.RunUsersAssem bly()
at System.Threadin g.ThreadHelper. ThreadStart_Con text(Object state)
at System.Threadin g.ExecutionCont ext.Run(Executi onContext
executionContex t, ContextCallback callback, Object state)
at
System.Threadin g.ThreadHelper. ThreadStart()</ExceptionString ></Exception></TraceRecord>
-------------------------------
Public Sub Catalog()
TOTAL_FILEKEEP = 0
ROOTFOLDER_DINC LAUSE = DinClause("ROOT FOLDERID", "ROOTFOLDER S",
"ACTIVE=1")
Dim rootFolderID As Integer
Dim RootFolder As String
Dim DR As New System.Data.Sql Client.SqlDataR eader
DR = Nothing
SetDataReader(D R, "EXEC spRootFoldersTo Catalog")
While DR.Read
RootFolder = DR.GetValue(1). ToString
rootFolderID = CInt(DR.GetValu e(0).ToString)
Call RootFolder_Cata log(RootFolder, rootFolderID)
End While
Files_Catalog()
End Sub
--------------------------------------------------------------------------------
Public Sub SetDataReader(B yRef thisDR As
System.Data.Sql Client.SqlDataR eader, ByVal strSql As String)
frmMain.WriteSt atus(strSql)
Dim cmd As New System.Data.Sql Client.SqlComma nd
cmd.CommandText = strSql
cmd.Connection = cnnX
Try
thisDR = cmd.ExecuteRead er
Catch ex As Exception
MsgBox(ex.ToStr ing)
End Try
End Sub
-----------------------------------------------
Public Sub RunSql(ByVal strSql As String)
Dim cmd As New System.Data.Sql Client.SqlComma nd
frmMain.WriteSt atus(strSql)
cmd.CommandText .Equals(strSql)
Try
cmd.ExecuteNonQ uery()
Catch ex As Exception
frmMain.WriteSt atus("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 (executeNonQuer y).
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.Transact ions Critical: 0 : <TraceRecord
xmlns="http://schemas.microso ft.com/2004/10/E2ETraceEvent/TraceRecord"
Severity="Criti cal"><TraceIden tifier>http://msdn.microsoft. com/TraceCodes/System/ActivityTracing/2004/07/Reliability/Exception/Unhandled</TraceIdentifier ><Description>U nhandled
exception</Description><Ap pDomain>FileMon .vshost.exe</AppDomain><Exce ption><Exceptio nType>System.Nu llReferenceExce ption,
mscorlib, Version=2.0.0.0 , Culture=neutral ,
PublicKeyToken= b77a5c561934e08 9</ExceptionType>< Message>Object
reference not set to an instance of an object.</Message><StackT race>
at FileMon.basCata log.Catalog() in C:\Documents and Settings\aarkem \My
Documents\Visua l Studio
2005\Projects\F ileMon8_2006050 1\FileMon_9\bas Catalog.vb:line 28
at FileMon.frmMain .Button1_Click( Object sender, EventArgs e) in
C:\Documents and Settings\aarkem \My Documents\Visua l Studio
2005\Projects\F ileMon8_2006050 1\FileMon_9\frm Main.vb:line 19
at System.Windows. Forms.Control.O nClick(EventArg s e)
at System.Windows. Forms.Button.On Click(EventArgs e)
at System.Windows. Forms.Button.On MouseUp(MouseEv entArgs mevent)
at System.Windows. Forms.Control.W mMouseUp(Messag e&amp; m,
MouseButtons button, Int32 clicks)
at System.Windows. Forms.Control.W ndProc(Message& amp;amp; m)
at System.Windows. Forms.ButtonBas e.WndProc(Messa ge&amp; m)
at System.Windows. Forms.Button.Wn dProc(Message&a mp;amp; m)
at
System.Windows. Forms.Control.C ontrolNativeWin dow.OnMessage(M essage&amp;
m)
at
System.Windows. Forms.Control.C ontrolNativeWin dow.WndProc(Mes sage&amp;
m)
at System.Windows. Forms.NativeWin dow.DebuggableC allback(IntPtr hWnd,
Int32 msg, IntPtr wparam, IntPtr lparam)
at
System.Windows. Forms.UnsafeNat iveMethods.Disp atchMessageW(MS G&amp;
msg)
at
System.Windows. Forms.Applicati on.ComponentMan ager.System.Win dows.Forms.Unsa feNativeMethods .IMsoComponentM anager.FPushMes sageLoop(Int32
dwComponentID, Int32 reason, Int32 pvLoopData)
at
System.Windows. Forms.Applicati on.ThreadContex t.RunMessageLoo pInner(Int32
reason, ApplicationCont ext context)
at
System.Windows. Forms.Applicati on.ThreadContex t.RunMessageLoo p(Int32
reason, ApplicationCont ext context)
at System.Windows. Forms.Applicati on.Run(Form mainForm)
at FileMon.frmMain .Main() in C:\Documents and Settings\aarkem \My
Documents\Visua l Studio
2005\Projects\F ileMon8_2006050 1\FileMon_9\frm Main.Designer.v b:line 2
at System.AppDomai n.nExecuteAssem bly(Assembly assembly, String[]
args)
at System.AppDomai n.ExecuteAssemb ly(String assemblyFile, Evidence
assemblySecurit y, String[] args)
at Microsoft.Visua lStudio.Hosting Process.HostPro c.RunUsersAssem bly()
at System.Threadin g.ThreadHelper. ThreadStart_Con text(Object state)
at System.Threadin g.ExecutionCont ext.Run(Executi onContext
executionContex t, ContextCallback callback, Object state)
at
System.Threadin g.ThreadHelper. ThreadStart()</StackTrace><Exc eptionString>Sy stem.NullRefere nceException:
Object reference not set to an instance of an object.
at FileMon.basCata log.Catalog() in C:\Documents and
Settings\aarkem \My Documents\Visua l Studio
2005\Projects\F ileMon8_2006050 1\FileMon_9\bas Catalog.vb:line 28
at FileMon.frmMain .Button1_Click( Object sender, EventArgs e) in
C:\Documents and Settings\aarkem \My Documents\Visua l Studio
2005\Projects\F ileMon8_2006050 1\FileMon_9\frm Main.vb:line 19
at System.Windows. Forms.Control.O nClick(EventArg s e)
at System.Windows. Forms.Button.On Click(EventArgs e)
at System.Windows. Forms.Button.On MouseUp(MouseEv entArgs mevent)
at System.Windows. Forms.Control.W mMouseUp(Messag e&amp; m,
MouseButtons button, Int32 clicks)
at System.Windows. Forms.Control.W ndProc(Message& amp;amp; m)
at System.Windows. Forms.ButtonBas e.WndProc(Messa ge&amp; m)
at System.Windows. Forms.Button.Wn dProc(Message&a mp;amp; m)
at
System.Windows. Forms.Control.C ontrolNativeWin dow.OnMessage(M essage&amp;
m)
at
System.Windows. Forms.Control.C ontrolNativeWin dow.WndProc(Mes sage&amp;
m)
at System.Windows. Forms.NativeWin dow.DebuggableC allback(IntPtr hWnd,
Int32 msg, IntPtr wparam, IntPtr lparam)
at
System.Windows. Forms.UnsafeNat iveMethods.Disp atchMessageW(MS G&amp;
msg)
at
System.Windows. Forms.Applicati on.ComponentMan ager.System.Win dows.Forms.Unsa feNativeMethods .IMsoComponentM anager.FPushMes sageLoop(Int32
dwComponentID, Int32 reason, Int32 pvLoopData)
at
System.Windows. Forms.Applicati on.ThreadContex t.RunMessageLoo pInner(Int32
reason, ApplicationCont ext context)
at
System.Windows. Forms.Applicati on.ThreadContex t.RunMessageLoo p(Int32
reason, ApplicationCont ext context)
at System.Windows. Forms.Applicati on.Run(Form mainForm)
at FileMon.frmMain .Main() in C:\Documents and Settings\aarkem \My
Documents\Visua l Studio
2005\Projects\F ileMon8_2006050 1\FileMon_9\frm Main.Designer.v b:line 2
at System.AppDomai n.nExecuteAssem bly(Assembly assembly, String[]
args)
at System.AppDomai n.ExecuteAssemb ly(String assemblyFile, Evidence
assemblySecurit y, String[] args)
at Microsoft.Visua lStudio.Hosting Process.HostPro c.RunUsersAssem bly()
at System.Threadin g.ThreadHelper. ThreadStart_Con text(Object state)
at System.Threadin g.ExecutionCont ext.Run(Executi onContext
executionContex t, ContextCallback callback, Object state)
at
System.Threadin g.ThreadHelper. ThreadStart()</ExceptionString ></Exception></TraceRecord>
-------------------------------
Public Sub Catalog()
TOTAL_FILEKEEP = 0
ROOTFOLDER_DINC LAUSE = DinClause("ROOT FOLDERID", "ROOTFOLDER S",
"ACTIVE=1")
Dim rootFolderID As Integer
Dim RootFolder As String
Dim DR As New System.Data.Sql Client.SqlDataR eader
DR = Nothing
SetDataReader(D R, "EXEC spRootFoldersTo Catalog")
While DR.Read
RootFolder = DR.GetValue(1). ToString
rootFolderID = CInt(DR.GetValu e(0).ToString)
Call RootFolder_Cata log(RootFolder, rootFolderID)
End While
Files_Catalog()
End Sub
--------------------------------------------------------------------------------
Public Sub SetDataReader(B yRef thisDR As
System.Data.Sql Client.SqlDataR eader, ByVal strSql As String)
frmMain.WriteSt atus(strSql)
Dim cmd As New System.Data.Sql Client.SqlComma nd
cmd.CommandText = strSql
cmd.Connection = cnnX
Try
thisDR = cmd.ExecuteRead er
Catch ex As Exception
MsgBox(ex.ToStr ing)
End Try
End Sub
-----------------------------------------------
Public Sub RunSql(ByVal strSql As String)
Dim cmd As New System.Data.Sql Client.SqlComma nd
frmMain.WriteSt atus(strSql)
cmd.CommandText .Equals(strSql)
Try
cmd.ExecuteNonQ uery()
Catch ex As Exception
frmMain.WriteSt atus("SQL FAILED: " & strSql)
Stop
End Try
End Sub
---------------------------------------------
Comment