|
Yes, post the code, it's the only way to be sure.
- S
50 cups of coffee and you know it's on!
Code, follow, or get out of the way.
|
|
|
|
|
here is the code:
Variables to check DropDownList State and to get the IndustryId for SubIndustry:
bool LoadSubIndustries = true;
public int IndustryId { get; set; }
Page_Load:
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
Populate_Industry();
}
LoadSubIndustries = false;
}
The Populate Methods:
private void Populate_SubIndustry()
{
DataSet dsSubIndustries = lookupManager.GetSubIndsutryByIndustryId(IndustryId);
ddlSubIndustry.DataSource = dsSubIndustries.Tables["Lookup_SubIndustry"].DefaultView;
ddlSubIndustry.DataValueField = "Id";
ddlSubIndustry.DataTextField = "SubIndustry";
ddlSubIndustry.DataBind();
}
private void Populate_Industry()
{
DataSet dsIndustries = lookupManager.GetIndustries();
ddlIndustry.DataSource = dsIndustries.Tables["Lookup_Industry"].DefaultView;
ddlIndustry.DataValueField = "Id";
ddlIndustry.DataTextField = "Industry";
ddlIndustry.DataBind();
}
SelectedIndex_Changed method:
protected void ddlIndustry_SelectedIndexChanged(object sender, EventArgs e)
{
if (LoadSubIndustries == false)
{
IndustryId = (int.Parse(ddlIndustry.SelectedValue.ToString()));
Populate_SubIndustry();
}
}
Illegal Operation
|
|
|
|
|
Steve,
Please ignore. I have found the problem. I have not added the table adapter to my GetSubIndustryByIndustryId method.
Boy do I feel like the idiot!!
Thanks for the quick response!!
Cheers
Illegal Operation
|
|
|
|
|
Ah, happy to be of service.
- S
50 cups of coffee and you know it's on!
Code, follow, or get out of the way.
|
|
|
|
|
Have you put a break point on the bolded line:
protected void ddlIndustry_SelectedIndexChanged(object sender, EventArgs e)
{
if (LoadSubIndustries == false)
{
IndustryId = (int.Parse(ddlIndustry.SelectedValue.ToString()));
Populate_SubIndustry();
}
}
to make sure LoadSubIndustries is false? Is it even getting into this event handler? If it's not getting to the event handler, that would indicate the event isn't wired up correctly.
- S
50 cups of coffee and you know it's on!
Code, follow, or get out of the way.
|
|
|
|
|
Dear All,
I using ASP.NET with AD. I can connect with my username and password, Can I get all username in AD?
Socheat
|
|
|
|
|
You want to authenticate user from Active Directory ? Or want to list of all user name from AD ?
Read this article, This will help you to find out all the answer.
Howto: (Almost) Everything In Active Directory via C#[^]
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
Yes, I want toget all user name from AD
Socheat
|
|
|
|
|
|
I need some help on how to validate the userName and password against a database for a login system in Visual C#? Help!!!!
|
|
|
|
|
First, read this[^]
Second, read this[^]
only two letters away from being an asset
|
|
|
|
|
Mark Nischalke wrote: First, read this[^]
I believe you meant this[^].
|
|
|
|
|
I hate it when they don't answer.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Yep, got the wrong one
only two letters away from being an asset
|
|
|
|
|
There is no such thing as APS.NET. I get the impression you have no idea what you're doing. That doesn't make for a secure login system. Perhaps you should pay someone to do it for you. Be careful if you decide to list this job on places like rentacoder, because some people advertise on places like that, take jobs they can't do, and post here asking us to do it for them. We tend not to do work for people who are being paid and have no clue.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
hello
i find a great article about data access, it is to sql
i change the data access to work with sybase
i change the sql object by sybase object
Protected Overloads Sub ExecuteNonQuery(ByRef cmd As AseCommand, ByRef procName As String, ByVal ParamArray
procParams() As IDataParameter)
'Method variablesoutDim cmd As SqlCommand
Dim cnx As AseConnection = Nothing
cmd = Nothing
'Avoids "Use of unassigned variable" compiler error
Try
'Setup command object
cmd = New AseCommand(procName)
cmd.CommandType = CommandType.StoredProcedure
Dim index As Integer = 0
Do While (index < procParams.Length)
cmd.Parameters.Add(procParams(index))
index = (index + 1)
Loop
'Determine the transaction owner and process accordingly
If _esIniciante Then
cnx = New AseConnection(GetConnectionString)
cmd.Connection = cnx
cnx.Open()
Else
cmd.Connection = _txn.Connection
cmd.Transaction = _txn
End If
'Execute the command
cmd.ExecuteNonQuery()
Catch ex As Exception
Throw
Finally
If _esIniciante Then
cnx.Dispose()
End If
If (Not (cmd) Is Nothing) Then
cmd.Dispose()
End If
End Try
End Sub
when call the function ExecuteNonQuery
Public Function Cliente_obtenerPorCedula(ByRef clienteID As Integer, ByVal cedula As String) As DataSet
Dim cmd As AseCommand
ExecuteNonQuery(cmd, "crm_co_clientecedula", _
CreateParameter("@i_cliente_id", AseDbType.Integer, clienteID, ParameterDirection.Output), _
CreateParameter("@i_cedula", AseDbType.NVarChar, cedula))
clienteID = CType(cmd.Parameters("@i_cliente_id").Value, Integer)
cmd.Dispose()
End Function
everything runs fine until invoke the code cmd.Parameters("@i_cliente_id").Value
ocurr the exception --> Run-time exception thrown : System.ObjectDisposedException - Cannot access a disposed object.
Object name: 'AseCommand: '.
the dispose cause exception
Catch ex As Exception
Throw
Finally
If _esIniciante Then
cnx.Dispose()
End If
If (Not (cmd) Is Nothing) Then
cmd.Dispose()
End If
End Try
the cmd.dispose -->System.ObjectDisposedException - Cannot access a disposed object.
the cnx.dispose -->Parameters {"Cannot access a disposed object.Object name: 'AseCommand: '.
while i comment this line, the code work
'If _esIniciante Then
' cnx.Dispose()
'End If
'If (Not (cmd) Is Nothing) Then
' cmd.Dispose()
'End If
where can be the problem ?
the original code is c# and sql that's work fine
me email is raquidd@yahoo.com
regards
sorry for me english
|
|
|
|
|
when you call
ExecuteNonQuery(cmd, "crm_co_clientecedula", _
CreateParameter("@i_cliente_id", AseDbType.Integer, clienteID, ParameterDirection.Output), _
CreateParameter("@i_cedula", AseDbType.NVarChar, cedula))
It will dispose cmd as it is ByRef. So cmd.Parameters will fail. Properties of Disposed object is inaccessible.
|
|
|
|
|
Abhishek Sur wrote: It will dispose cmd as it is ByRef.
This is not because it is passed as ByRef . It will get disposed even you pass as ByVal .
|
|
|
|
|
I dont know if you tried this in VB or not.
Initially this was my conception as well... I thought everything that is not derived from ValueTypes are called ByRef.
But it isnt actually.
If you call using ByVal , you can change any properties inside the object and it will reflect the caller, but it will not allow setting the actual object to Nothing or Dispose it. Only If you call using ByRef it allows this.
You may try out this :
Dim b As New SqlClient.SqlCommand()
x(b)
b.CommandText = "" ' this will allow Because of ByVal but will assign ' value ddd to CommandText
Public Sub x(ByVal rr As SqlClient.SqlCommand)
rr.CommandText = "dddd"
rr.Dispose()
rr = nothing
End Sub
You can try this.
Even this does happen in C#.
private void button1_Click(object sender, EventArgs e)
{
SqlCommand cmd = new SqlCommand();
this.x(ref cmd);
cmd.CommandText = "";
}
private void x(ref SqlCommand com)
{
com = null;
}
Just removing the ref keyword will allow this ...
|
|
|
|
|
Abhishek Sur wrote: I thought everything that is not derived from ValueTypes are called ByRef.
But it isnt actually.
In .NET, parameters are passed by value by default. A reference type is passed as value but the value will be a reference. This is the reason why setting null is reflecting at the caller side. But you still can call Dispose() as it is just a method in the type.
|
|
|
|
|
I got your point budd.. Cool...
|
|
|
|
|
thanks all
thanks Abhishek Sur
i tested the example in c# and vb, this working.
i read more about byval to understand how the variable b receive the change the variable rr
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'prueba 1
Dim b As New SqlClient.SqlCommand()
Prueba1(b)
''here the variable b have commandtext="ddddddd", commandtimeout=45,
''CommandType = CommandType.StoredProcedure
b.CommandText = ""
'prueba 2
End Sub
Public Sub Prueba1(ByVal rr As SqlClient.SqlCommand)
rr.CommandText = "dddd"
rr.CommandTimeout = 45
rr.CommandType = CommandType.StoredProcedure
rr.Dispose()
rr = Nothing
End Sub
thanks
|
|
|
|
|
What is the point in adding parameters after calling ExecuteNonQuery ?
Next time,
1) Please format your code while posting. Use pre tags.
2) Stop posting email addresses. That is not how this forum works.
|
|
|
|
|
thank for all
thanks N a v a n e e t h
i understand all coment about byval o vbyref, first time i see the out parameter in c#.
the code original is and working, i tested.
public class PersonDataService
public void Person_Save(ref int personID, string nameFirst, string nameLast, DateTime dob)
{
SqlCommand cmd;
ExecuteNonQuery(out cmd, "Person_Save",
CreateParameter("@PersonID", SqlDbType.Int, personID, ParameterDirection.InputOutput),
CreateParameter("@NameFirst", SqlDbType.NVarChar, nameFirst),
CreateParameter("@NameLast", SqlDbType.NVarChar, nameLast),
CreateParameter("@DOB", SqlDbType.DateTime, dob));
personID = (int)cmd.Parameters["@PersonID"].Value;
cmd.Dispose();
}
and the class
protected void ExecuteNonQuery(string procName,
params IDataParameter[] procParams)
{
SqlCommand cmd;
ExecuteNonQuery(out cmd, procName, procParams);
}
protected void ExecuteNonQuery(out SqlCommand cmd, string procName,
params IDataParameter[] procParams)
{
SqlConnection cnx = null;
cmd = null;
try
{
cmd = new SqlCommand(procName);
cmd.CommandType = CommandType.StoredProcedure;
for (int index = 0; index < procParams.Length; index++)
{
cmd.Parameters.Add(procParams[index]);
}
if (_isOwner)
{
cnx = new SqlConnection(GetConnectionString());
cmd.Connection = cnx;
cnx.Open();
}
else
{
cmd.Connection = _txn.Connection;
cmd.Transaction = _txn;
}
cmd.ExecuteNonQuery();
}
catch
{
throw;
}
finally
{
if (_isOwner)
{
cnx.Dispose();
}
if (cmd != null) cmd.Dispose();
}
}
regards,
MS
|
|
|
|
|
i will translate to vb, but with ref parameter dont work
|
|
|
|