Showing posts with label sub. Show all posts
Showing posts with label sub. Show all posts

Saturday, March 31, 2012

Subprocedure for Oracle's SET DEFINE OFF command

I want to create a procedure in ASP.NET to run the "SET DEFINE OFF" command
in an Oracle database. I tried the following:
Public Shared Sub SetDefineOff()
Dim myconnection As New
OracleConnection(ConfigurationSettings.AppSettings("connectionstring"))
Dim cmdsetdefineoff As New OracleCommand("SET DEFINE OFF", myconnection)
myconnection.Open()
cmdsetdefineoff.ExecuteNonQuery()
myconnection.Close()
End Sub
But I recieve the following error:
Server Error in '/lvbeporgtest' Application.
----
--
ORA-00922: missing or invalid option
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.
Exception Details: System.Data.OracleClient.OracleException: ORA-00922:
missing or invalid option
Source Error:
An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of the
exception can be identified using the exception stack trace below.
Stack Trace:
[OracleException: ORA-00922: missing or invalid option
]
System.Data.OracleClient.OracleConnection.CheckError(OciErrorHandle
errorHandle, Int32 rc) +174
System.Data.OracleClient.OracleCommand.Execute(OciHandle statementHandle,
CommandBehavior behavior, Boolean isReader, Boolean needRowid, OciHandle&
rowidDescriptor, ArrayList& refCursorParameterOrdinals) +1919
System.Data.OracleClient.OracleCommand.Execute(OciHandle statementHandle,
CommandBehavior behavior, Boolean needRowid, OciHandle& rowidDescriptor) +32
System.Data.OracleClient.OracleCommand.ExecuteNonQueryInternal(Boolean
needRowid, OciHandle& rowidDescriptor) +170
System.Data.OracleClient.OracleCommand.ExecuteNonQuery() +56
Global.SetDefineOff() in C:\Documents and Settings\Nathan
Sokalski\VSWebCache\www.webdevlccc.com\lvbeporgtest\Global.asax.vb:32
newmin.btnSubmitNotesLink_Click(Object sender, EventArgs e) in
C:\Documents and Settings\Nathan
Sokalski\VSWebCache\[url]www.webdevlccc.com\lvbeporgtest\newmin.aspx.vb:71[/url]
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePo
stBackEvent(String
eventArgument) +57
System.Web.UI.Page. RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1292
----
--
Version Information: Microsoft .NET Framework Version:1.1.4322.2300; ASP.NET
Version:1.1.4322.2300
Can someone tell me what I am doing wrong or what is causing the error and
what I can do to fix it? Thanks.
--
Nathan Sokalski
njsokalski@dotnet.itags.org.hotmail.com
http://www.nathansokalski.com/Hi Nathan,
I am no Oracle expert but I can tell you two things:
1. Your code is fine, you aren't doing anything wrong.
2. "SET DEFINE OFF" is not a SQL command, it is a SQL *Plus command. It
just won't work Oracle has no idea what you mean.
Tim
"Nathan Sokalski" wrote:

> I want to create a procedure in ASP.NET to run the "SET DEFINE OFF" comman
d
> in an Oracle database. I tried the following:
> Public Shared Sub SetDefineOff()
> Dim myconnection As New
> OracleConnection(ConfigurationSettings.AppSettings("connectionstring"))
> Dim cmdsetdefineoff As New OracleCommand("SET DEFINE OFF", myconnection)
> myconnection.Open()
> cmdsetdefineoff.ExecuteNonQuery()
> myconnection.Close()
> End Sub
>
> But I recieve the following error:
> Server Error in '/lvbeporgtest' Application.
> ----
--
> ORA-00922: missing or invalid option
> Description: An unhandled exception occurred during the execution of the
> current web request. Please review the stack trace for more information
> about the error and where it originated in the code.
> Exception Details: System.Data.OracleClient.OracleException: ORA-00922:
> missing or invalid option
> Source Error:
> An unhandled exception was generated during the execution of the
> current web request. Information regarding the origin and location of the
> exception can be identified using the exception stack trace below.
> Stack Trace:
> [OracleException: ORA-00922: missing or invalid option
> ]
> System.Data.OracleClient.OracleConnection.CheckError(OciErrorHandle
> errorHandle, Int32 rc) +174
> System.Data.OracleClient.OracleCommand.Execute(OciHandle statementHandl
e,
> CommandBehavior behavior, Boolean isReader, Boolean needRowid, OciHandle&
> rowidDescriptor, ArrayList& refCursorParameterOrdinals) +1919
> System.Data.OracleClient.OracleCommand.Execute(OciHandle statementHandl
e,
> CommandBehavior behavior, Boolean needRowid, OciHandle& rowidDescriptor) +
32
> System.Data.OracleClient.OracleCommand.ExecuteNonQueryInternal(Boolean
> needRowid, OciHandle& rowidDescriptor) +170
> System.Data.OracleClient.OracleCommand.ExecuteNonQuery() +56
> Global.SetDefineOff() in C:\Documents and Settings\Nathan
> Sokalski\VSWebCache\www.webdevlccc.com\lvbeporgtest\Global.asax.vb:32
> newmin.btnSubmitNotesLink_Click(Object sender, EventArgs e) in
> C:\Documents and Settings\Nathan
> Sokalski\VSWebCache\[url]www.webdevlccc.com\lvbeporgtest\newmin.aspx.vb:71[/url]
> System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
> System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.Ra
isePostBackEvent(String
> eventArgument) +57
> System.Web.UI.Page. RaisePostBackEvent(IPostBackEventHandler
> sourceControl, String eventArgument) +18
> System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
> System.Web.UI.Page.ProcessRequestMain() +1292
>
> ----
--
> Version Information: Microsoft .NET Framework Version:1.1.4322.2300; ASP.N
ET
> Version:1.1.4322.2300
>
> Can someone tell me what I am doing wrong or what is causing the error and
> what I can do to fix it? Thanks.
> --
> Nathan Sokalski
> njsokalski@.hotmail.com
> http://www.nathansokalski.com/
>
>
I would recommend that rather than making this a separate command he
include this line at the beginning of whatever stored procedure on
Oracle that he wants to run.
Sort of like in a SQL procedure where you start with SET ANSI OFF.
timkling wrote:
> Hi Nathan,
> I am no Oracle expert but I can tell you two things:
> 1. Your code is fine, you aren't doing anything wrong.
> 2. "SET DEFINE OFF" is not a SQL command, it is a SQL *Plus command. It
> just won't work Oracle has no idea what you mean.
> Tim
> "Nathan Sokalski" wrote:
>
You might need to wrap the SET DEFINE OFF in a BEGIN/END block:
BEGIN SET DEFINE OFF; END;
I've not used Oracle for a couple of years so the syntax might not be correc
t.
"Nathan Sokalski" wrote:

> I want to create a procedure in ASP.NET to run the "SET DEFINE OFF" comman
d
> in an Oracle database. I tried the following:
> Public Shared Sub SetDefineOff()
> Dim myconnection As New
> OracleConnection(ConfigurationSettings.AppSettings("connectionstring"))
> Dim cmdsetdefineoff As New OracleCommand("SET DEFINE OFF", myconnection)
> myconnection.Open()
> cmdsetdefineoff.ExecuteNonQuery()
> myconnection.Close()
> End Sub
>
> But I recieve the following error:
> Server Error in '/lvbeporgtest' Application.
> ----
--
> ORA-00922: missing or invalid option
> Description: An unhandled exception occurred during the execution of the
> current web request. Please review the stack trace for more information
> about the error and where it originated in the code.
> Exception Details: System.Data.OracleClient.OracleException: ORA-00922:
> missing or invalid option
> Source Error:
> An unhandled exception was generated during the execution of the
> current web request. Information regarding the origin and location of the
> exception can be identified using the exception stack trace below.
> Stack Trace:
> [OracleException: ORA-00922: missing or invalid option
> ]
> System.Data.OracleClient.OracleConnection.CheckError(OciErrorHandle
> errorHandle, Int32 rc) +174
> System.Data.OracleClient.OracleCommand.Execute(OciHandle statementHandl
e,
> CommandBehavior behavior, Boolean isReader, Boolean needRowid, OciHandle&
> rowidDescriptor, ArrayList& refCursorParameterOrdinals) +1919
> System.Data.OracleClient.OracleCommand.Execute(OciHandle statementHandl
e,
> CommandBehavior behavior, Boolean needRowid, OciHandle& rowidDescriptor) +
32
> System.Data.OracleClient.OracleCommand.ExecuteNonQueryInternal(Boolean
> needRowid, OciHandle& rowidDescriptor) +170
> System.Data.OracleClient.OracleCommand.ExecuteNonQuery() +56
> Global.SetDefineOff() in C:\Documents and Settings\Nathan
> Sokalski\VSWebCache\www.webdevlccc.com\lvbeporgtest\Global.asax.vb:32
> newmin.btnSubmitNotesLink_Click(Object sender, EventArgs e) in
> C:\Documents and Settings\Nathan
> Sokalski\VSWebCache\[url]www.webdevlccc.com\lvbeporgtest\newmin.aspx.vb:71[/url]
> System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
> System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.Ra
isePostBackEvent(String
> eventArgument) +57
> System.Web.UI.Page. RaisePostBackEvent(IPostBackEventHandler
> sourceControl, String eventArgument) +18
> System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
> System.Web.UI.Page.ProcessRequestMain() +1292
>
> ----
--
> Version Information: Microsoft .NET Framework Version:1.1.4322.2300; ASP.N
ET
> Version:1.1.4322.2300
>
> Can someone tell me what I am doing wrong or what is causing the error and
> what I can do to fix it? Thanks.
> --
> Nathan Sokalski
> njsokalski@.hotmail.com
> http://www.nathansokalski.com/
>
>

Subprocedure for Oracles SET DEFINE OFF command

I want to create a procedure in ASP.NET to run the "SET DEFINE OFF" command
in an Oracle database. I tried the following:

Public Shared Sub SetDefineOff()

Dim myconnection As New
OracleConnection(ConfigurationSettings.AppSettings ("connectionstring"))

Dim cmdsetdefineoff As New OracleCommand("SET DEFINE OFF", myconnection)

myconnection.Open()

cmdsetdefineoff.ExecuteNonQuery()

myconnection.Close()

End Sub

But I recieve the following error:

Server Error in '/lvbeporgtest' Application.
------------------------

ORA-00922: missing or invalid option
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Data.OracleClient.OracleException: ORA-00922:
missing or invalid option

Source Error:

An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of the
exception can be identified using the exception stack trace below.

Stack Trace:

[OracleException: ORA-00922: missing or invalid option
]
System.Data.OracleClient.OracleConnection.CheckErr or(OciErrorHandle
errorHandle, Int32 rc) +174
System.Data.OracleClient.OracleCommand.Execute(Oci Handle statementHandle,
CommandBehavior behavior, Boolean isReader, Boolean needRowid, OciHandle&
rowidDescriptor, ArrayList& refCursorParameterOrdinals) +1919
System.Data.OracleClient.OracleCommand.Execute(Oci Handle statementHandle,
CommandBehavior behavior, Boolean needRowid, OciHandle& rowidDescriptor) +32
System.Data.OracleClient.OracleCommand.ExecuteNonQ ueryInternal(Boolean
needRowid, OciHandle& rowidDescriptor) +170
System.Data.OracleClient.OracleCommand.ExecuteNonQ uery() +56
Global.SetDefineOff() in C:\Documents and Settings\Nathan
Sokalski\VSWebCache\http://www.webdevlccc.com\lvbeporgt...obal.asax.vb:32
newsadmin.btnSubmitNotesLink_Click(Object sender, EventArgs e) in
C:\Documents and Settings\Nathan
Sokalski\VSWebCache\http://www.webdevlccc.com\lvbeporgt...in.aspx.vb: 71
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String
eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1292

------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.2300; ASP.NET
Version:1.1.4322.2300

Can someone tell me what I am doing wrong or what is causing the error and
what I can do to fix it? Thanks.
--
Nathan Sokalski
njsokalski@dotnet.itags.org.hotmail.com
http://www.nathansokalski.com/Hi Nathan,

I am no Oracle expert but I can tell you two things:

1. Your code is fine, you aren't doing anything wrong.
2. "SET DEFINE OFF" is not a SQL command, it is a SQL *Plus command. It
just won't work Oracle has no idea what you mean.

Tim

"Nathan Sokalski" wrote:

> I want to create a procedure in ASP.NET to run the "SET DEFINE OFF" command
> in an Oracle database. I tried the following:
> Public Shared Sub SetDefineOff()
> Dim myconnection As New
> OracleConnection(ConfigurationSettings.AppSettings ("connectionstring"))
> Dim cmdsetdefineoff As New OracleCommand("SET DEFINE OFF", myconnection)
> myconnection.Open()
> cmdsetdefineoff.ExecuteNonQuery()
> myconnection.Close()
> End Sub
>
> But I recieve the following error:
> Server Error in '/lvbeporgtest' Application.
> ------------------------
> ORA-00922: missing or invalid option
> Description: An unhandled exception occurred during the execution of the
> current web request. Please review the stack trace for more information
> about the error and where it originated in the code.
> Exception Details: System.Data.OracleClient.OracleException: ORA-00922:
> missing or invalid option
> Source Error:
> An unhandled exception was generated during the execution of the
> current web request. Information regarding the origin and location of the
> exception can be identified using the exception stack trace below.
> Stack Trace:
> [OracleException: ORA-00922: missing or invalid option
> ]
> System.Data.OracleClient.OracleConnection.CheckErr or(OciErrorHandle
> errorHandle, Int32 rc) +174
> System.Data.OracleClient.OracleCommand.Execute(Oci Handle statementHandle,
> CommandBehavior behavior, Boolean isReader, Boolean needRowid, OciHandle&
> rowidDescriptor, ArrayList& refCursorParameterOrdinals) +1919
> System.Data.OracleClient.OracleCommand.Execute(Oci Handle statementHandle,
> CommandBehavior behavior, Boolean needRowid, OciHandle& rowidDescriptor) +32
> System.Data.OracleClient.OracleCommand.ExecuteNonQ ueryInternal(Boolean
> needRowid, OciHandle& rowidDescriptor) +170
> System.Data.OracleClient.OracleCommand.ExecuteNonQ uery() +56
> Global.SetDefineOff() in C:\Documents and Settings\Nathan
> Sokalski\VSWebCache\http://www.webdevlccc.com\lvbeporgt...obal.asax.vb:32
> newsadmin.btnSubmitNotesLink_Click(Object sender, EventArgs e) in
> C:\Documents and Settings\Nathan
> Sokalski\VSWebCache\http://www.webdevlccc.com\lvbeporgt...in.aspx.vb: 71
> System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
> System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String
> eventArgument) +57
> System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
> sourceControl, String eventArgument) +18
> System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +33
> System.Web.UI.Page.ProcessRequestMain() +1292
>
> ------------------------
> Version Information: Microsoft .NET Framework Version:1.1.4322.2300; ASP.NET
> Version:1.1.4322.2300
>
> Can someone tell me what I am doing wrong or what is causing the error and
> what I can do to fix it? Thanks.
> --
> Nathan Sokalski
> njsokalski@.hotmail.com
> http://www.nathansokalski.com/
>
I would recommend that rather than making this a separate command he
include this line at the beginning of whatever stored procedure on
Oracle that he wants to run.

Sort of like in a SQL procedure where you start with SET ANSI OFF.

timkling wrote:
> Hi Nathan,
> I am no Oracle expert but I can tell you two things:
> 1. Your code is fine, you aren't doing anything wrong.
> 2. "SET DEFINE OFF" is not a SQL command, it is a SQL *Plus command. It
> just won't work Oracle has no idea what you mean.
> Tim
> "Nathan Sokalski" wrote:
>
>>I want to create a procedure in ASP.NET to run the "SET DEFINE OFF" command
>>in an Oracle database. I tried the following:
>>
>>Public Shared Sub SetDefineOff()
>>
>>Dim myconnection As New
>>OracleConnection(ConfigurationSettings.AppSettings ("connectionstring"))
>>
>>Dim cmdsetdefineoff As New OracleCommand("SET DEFINE OFF", myconnection)
>>
>>myconnection.Open()
>>
>>cmdsetdefineoff.ExecuteNonQuery()
>>
>>myconnection.Close()
>>
>>End Sub
>>
>>
>>But I recieve the following error:
>>
>>Server Error in '/lvbeporgtest' Application.
>>------------------------
>>
>>ORA-00922: missing or invalid option
>>Description: An unhandled exception occurred during the execution of the
>>current web request. Please review the stack trace for more information
>>about the error and where it originated in the code.
>>
>>Exception Details: System.Data.OracleClient.OracleException: ORA-00922:
>>missing or invalid option
>>
>>Source Error:
>>
>> An unhandled exception was generated during the execution of the
>>current web request. Information regarding the origin and location of the
>>exception can be identified using the exception stack trace below.
>>
>>Stack Trace:
>>
>>[OracleException: ORA-00922: missing or invalid option
>>]
>> System.Data.OracleClient.OracleConnection.CheckErr or(OciErrorHandle
>>errorHandle, Int32 rc) +174
>> System.Data.OracleClient.OracleCommand.Execute(Oci Handle statementHandle,
>>CommandBehavior behavior, Boolean isReader, Boolean needRowid, OciHandle&
>>rowidDescriptor, ArrayList& refCursorParameterOrdinals) +1919
>> System.Data.OracleClient.OracleCommand.Execute(Oci Handle statementHandle,
>>CommandBehavior behavior, Boolean needRowid, OciHandle& rowidDescriptor) +32
>> System.Data.OracleClient.OracleCommand.ExecuteNonQ ueryInternal(Boolean
>>needRowid, OciHandle& rowidDescriptor) +170
>> System.Data.OracleClient.OracleCommand.ExecuteNonQ uery() +56
>> Global.SetDefineOff() in C:\Documents and Settings\Nathan
>>Sokalski\VSWebCache\http://www.webdevlccc.com\lvbeporgt...obal.asax.vb:32
>> newsadmin.btnSubmitNotesLink_Click(Object sender, EventArgs e) in
>>C:\Documents and Settings\Nathan
>>Sokalski\VSWebCache\http://www.webdevlccc.com\lvbeporgt...in.aspx.vb: 71
>> System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
>> System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String
>>eventArgument) +57
>> System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
>>sourceControl, String eventArgument) +18
>> System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +33
>> System.Web.UI.Page.ProcessRequestMain() +1292
>>
>>
>>
>>------------------------
>>Version Information: Microsoft .NET Framework Version:1.1.4322.2300; ASP.NET
>>Version:1.1.4322.2300
>>
>>
>>Can someone tell me what I am doing wrong or what is causing the error and
>>what I can do to fix it? Thanks.
>>--
>>Nathan Sokalski
>>njsokalski@.hotmail.com
>>http://www.nathansokalski.com/
>>
>>
>>
You might need to wrap the SET DEFINE OFF in a BEGIN/END block:
BEGIN SET DEFINE OFF; END;

I've not used Oracle for a couple of years so the syntax might not be correct.

"Nathan Sokalski" wrote:

> I want to create a procedure in ASP.NET to run the "SET DEFINE OFF" command
> in an Oracle database. I tried the following:
> Public Shared Sub SetDefineOff()
> Dim myconnection As New
> OracleConnection(ConfigurationSettings.AppSettings ("connectionstring"))
> Dim cmdsetdefineoff As New OracleCommand("SET DEFINE OFF", myconnection)
> myconnection.Open()
> cmdsetdefineoff.ExecuteNonQuery()
> myconnection.Close()
> End Sub
>
> But I recieve the following error:
> Server Error in '/lvbeporgtest' Application.
> ------------------------
> ORA-00922: missing or invalid option
> Description: An unhandled exception occurred during the execution of the
> current web request. Please review the stack trace for more information
> about the error and where it originated in the code.
> Exception Details: System.Data.OracleClient.OracleException: ORA-00922:
> missing or invalid option
> Source Error:
> An unhandled exception was generated during the execution of the
> current web request. Information regarding the origin and location of the
> exception can be identified using the exception stack trace below.
> Stack Trace:
> [OracleException: ORA-00922: missing or invalid option
> ]
> System.Data.OracleClient.OracleConnection.CheckErr or(OciErrorHandle
> errorHandle, Int32 rc) +174
> System.Data.OracleClient.OracleCommand.Execute(Oci Handle statementHandle,
> CommandBehavior behavior, Boolean isReader, Boolean needRowid, OciHandle&
> rowidDescriptor, ArrayList& refCursorParameterOrdinals) +1919
> System.Data.OracleClient.OracleCommand.Execute(Oci Handle statementHandle,
> CommandBehavior behavior, Boolean needRowid, OciHandle& rowidDescriptor) +32
> System.Data.OracleClient.OracleCommand.ExecuteNonQ ueryInternal(Boolean
> needRowid, OciHandle& rowidDescriptor) +170
> System.Data.OracleClient.OracleCommand.ExecuteNonQ uery() +56
> Global.SetDefineOff() in C:\Documents and Settings\Nathan
> Sokalski\VSWebCache\http://www.webdevlccc.com\lvbeporgt...obal.asax.vb:32
> newsadmin.btnSubmitNotesLink_Click(Object sender, EventArgs e) in
> C:\Documents and Settings\Nathan
> Sokalski\VSWebCache\http://www.webdevlccc.com\lvbeporgt...in.aspx.vb: 71
> System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
> System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String
> eventArgument) +57
> System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
> sourceControl, String eventArgument) +18
> System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +33
> System.Web.UI.Page.ProcessRequestMain() +1292
>
> ------------------------
> Version Information: Microsoft .NET Framework Version:1.1.4322.2300; ASP.NET
> Version:1.1.4322.2300
>
> Can someone tell me what I am doing wrong or what is causing the error and
> what I can do to fix it? Thanks.
> --
> Nathan Sokalski
> njsokalski@.hotmail.com
> http://www.nathansokalski.com/
>

Subrotine

Hi !
Greetings to all!
Can anybody explain why we have to write "s as object, e as eventargs " in sub routine.
with advance thanx
VijayWhen using event handlers these objects are used to provide your event handler with info about the event and what object caused the event.
Hi Vijay,

s is the object which called the subroutine and
e is the arguments of the event associated with the object.

If you are using Visual Studio then try the different properties of s and e

hope this helps

Substitue ItemArray with something else in a FormView

When loading a FormView I try to fill a third-party combo control with
this code:
Protected Sub FormView1_ItemCreated(ByVal sender As Object, ByVal e As
EventArgs)
If FormView1.Row.RowState = DataControlRowState.Edit Then
Dim rowView As DataRowView = TryCast(FormView1.DataItem,
DataRowView)
If Not rowView Is Nothing Then
'Get and fill cboProject
Dim strProjectID As String =
TryCast(rowView.Row.ItemArray(8), String)
Dim cboProject As WebCombo =
TryCast(FormView1.FindControl("cboProject"), WebCombo)
cboProject.Value = strProjectID
End If
End If
End Sub
It works great except that I would like to change
"TryCast(rowView.Row.ItemArray(8), String)" and use the column name
instead of ItemArray(8). I have many columns in the FormView so it's
very difficult for me to guess which number represents a certain
column.
How can this be done?
I'm very grateful for help!
// SHi there,
First of all it's better to move databound-releated code to DataBound event
handler. Second you can access column by names directly from DataRowView:
protected Sub FormView1_DataBound( _
ByVal sender As Object, _
ByVal e As EventArgs)
dim formView as FormView = DirectCast(sender, FormView)
if formView.CurrentMode = FormViewMode.Edit then
Dim rowView As DataRowView = TryCast( _
formView.DataItem, DataRowView)
Dim cboProject as WebCombo = TryCast( _
formView.FindControl("cboProject"), WebControl)
cboProject.Value = Convert.ToString(rowView("ColumnName"))
end if
end sub
Hope this helps
--
Milosz
"staeri@.gmail.com" wrote:

> When loading a FormView I try to fill a third-party combo control with
> this code:
> Protected Sub FormView1_ItemCreated(ByVal sender As Object, ByVal e As
> EventArgs)
> If FormView1.Row.RowState = DataControlRowState.Edit Then
> Dim rowView As DataRowView = TryCast(FormView1.DataItem,
> DataRowView)
> If Not rowView Is Nothing Then
> 'Get and fill cboProject
> Dim strProjectID As String =
> TryCast(rowView.Row.ItemArray(8), String)
> Dim cboProject As WebCombo =
> TryCast(FormView1.FindControl("cboProject"), WebCombo)
> cboProject.Value = strProjectID
> End If
> End If
> End Sub
> It works great except that I would like to change
> "TryCast(rowView.Row.ItemArray(8), String)" and use the column name
> instead of ItemArray(8). I have many columns in the FormView so it's
> very difficult for me to guess which number represents a certain
> column.
> How can this be done?
> I'm very grateful for help!
> // S
>

Thursday, March 22, 2012

supervision on mass e mail sending

i use a loop to send e mail to all my site users, and using this procedure for the work:

Sub Mailshot(ByVal adress As String, ByVal subject As String, ByVal body As String)
Dim msgmail As MailMessage = New MailMessage()

SmtpMail.SmtpServer = "smtp.012.net.il"
msgmail.From = "shoresh@dotnet.itags.org.shoresh.org.il"

Try
msgmail.To = adress
msgmail.Body = body
msgmail.Subject = subject
msgmail.BodyFormat = MailFormat.Html
SmtpMail.Send(msgmail)
Catch exc As Exception
'DO WHATEVER ERROR HANDLING
End Try
msgmail = Nothing
End Sub

my site have something like 1000 users. and i call the sub one by one (for...next loop)

I have two questions about this e mail sending:
1) does this loop is going to overflow? if yes, what should i do to prevent it?
2) do i have any way to supervise the sending progress, i should to refresh the page every time, something that i think is not so good idea!!

thanksA For...Next loop is better suited for what you are trying to acomplish
i do use a for next loop to call the sending procedure. i wondered if this calling again and again wont stuck it.
Can you create a group and put all your users on it and then just send an email to the group?