|
nicknotyet wrote: One Yes and One No - I am well confused.
my bad. I have to read your post again. scottgp is right, you can not access client machine from asp.net. I read your post as you want to access server files.
The only way you can access client machines is through explicit permission of the use and other technologies such as activex.
sorry of the confusion, I take my earlier post back
|
|
|
|
|
No worries, at least I can make an informed decision.
I am kind of inclined to just do this old-school and roll my own pseudo database and write the app in straight C/++. It will be screaming fast and have no platform dependencies. The time I would have spent ramping up on SQL, .NET, DAO, IIS, etc, can be spent on implementation.
Thanks again for the input.
NIK
|
|
|
|
|
I have a query suppossed to return average values (SELECT AVG(DATA_VALUE)....).
However, it returns null when no data is present for the matching criteria.
I am using a data reader to read the value. like:
<br />
dr = cmdSelect.ExecuteReader();<br />
if (dr.HasRows)<br />
{<br />
dr.Read();<br />
string getAvg = dr.GetString(0);<br />
if (getAvg != null)<br />
{<br />
valArr[0] = Convert.ToDouble(getAvg);<br />
log.Add(...);<br />
}<br />
else{...}<br />
} <br />
Funny thing is - dr.HasRows is true because the query is returning a record even though the value is null. I also tried GetObject(0) instead of GetString(0), and tried cmd.ExecuteScalar() instead of ExecuteReader(), but still could not manage it. Its going to an Exception saying - "Data is Null. This method or property cannot be called on Null values."
Any help? Thanks.
|
|
|
|
|
all you need is DBNull[^]class
<br />
if (! DBNull.Value.Equals(dr[fieldName])) <br />
{<br />
}
|
|
|
|
|
You can handle that as below:
if (dr["fieldname"] != null)
{
//do something
}
|
|
|
|
|
|
I have tree view control on my asp.net web page.
this tree control has check boxes on every node.
I want when user selects or make parent node check box checked then its child should also get checked automatically.
how can i do this ?
kindly its urgent, plz send some code hints.
|
|
|
|
|
Write some fancy javascript to update all the sub nodes that contain a checkbox, or put the treeview in an ajax panel and use server side code to check all the checkboxes.
I didn't get any requirements for the signature
|
|
|
|
|
we r using asp.net and we have also created check boxes, we want parent node check box checked then its child should also get checked automatically.
|
|
|
|
|
enumerate though the childnodes and check the checkboxes.
Post your code so you can get further help.
|
|
|
|
|
heres the code
public partial class _Default : System.Web.UI.Page
{
public static SqlConnection sqlConn = new SqlConnection();
public static SqlCommand sqlCmmd = new SqlCommand();
public static SqlDataAdapter sqlDAptr = new SqlDataAdapter();
protected void Page_Load(object sender, EventArgs e)
{
try
{
PassQuery();
}
catch (Exception)
{
throw;
}
}
public void PassQuery()
{
this.TreeView1.Nodes.Clear();
DataSet myFirstTable = new DataSet();
string Query = "select name from sys.tables";
myFirstTable = Retun_Table_BasedOn_Query(Query);
DataSet[] mySecondTable = new DataSet[myFirstTable.Tables[0].Rows.Count];
for (int i = 0; i < myFirstTable.Tables["Table"].Rows.Count; i++)
{
string str1 = myFirstTable.Tables["Table"].Rows[i][0].ToString();
string Query2 = "SELECT sysobjects.name As Names, syscolumns.name AS FieldName " +
"FROM sysobjects INNER JOIN syscolumns ON sysobjects.id = syscolumns.id " +
"WHERE (sysobjects.name = '" + str1 + "')";
mySecondTable[i] = Retun_Table_BasedOn_Query(Query2);
TreeNode tnParent;
TreeNode tnChild;
for (int a = 0; a < 1; a++)
{
tnParent = new TreeNode();
tnParent.Text = str1.ToString();
TreeView1.Nodes.Add(tnParent);
foreach (DataRow rowChild in mySecondTable[i].Tables["Table"].Rows)
{
tnChild = new TreeNode();
tnChild.Text = rowChild["FieldName"].ToString();
tnParent.ChildNodes.Add(tnChild);
}
}
}
}
public void Open_Connection()
{
string Conn_Str = "Data Source=dev-test;Initial Catalog=Malik;Persist Security Info=True;User ID=interns;Password=intern123";
sqlConn = new SqlConnection(Conn_Str);
if (sqlConn.State != ConnectionState.Open)
{
sqlConn.Open();
}
}
public DataSet Retun_Table_BasedOn_Query(String Query)
{
Open_Connection();
DataSet mydataSet = new DataSet();
sqlCmmd = new SqlCommand(Query, sqlConn);
sqlDAptr = new SqlDataAdapter(sqlCmmd);
sqlDAptr.Fill(mydataSet);
return mydataSet;
}
}
help
|
|
|
|
|
T_Teef wrote:
Open_Connection();
DataSet mydataSet = new DataSet();
sqlCmmd = new SqlCommand(Query, sqlConn);
sqlDAptr = new SqlDataAdapter(sqlCmmd);
sqlDAptr.Fill(mydataSet);
return mydataSet;
FYI. If you pass an open connection to a SqlDataAdapter it will not close automatically. Check your sql server you probably have a bunch open connections that aren't being closed.
Also, where is your code to handle the treeviews click event?
I didn't get any requirements for the signature
|
|
|
|
|
thats why we have posted the code to get the help to obtain a piece of code to handle the treeviews click event
|
|
|
|
|
hello,
i want to add a "hello ___" to all my pages.
now , in order not to duplicate code , i can put it in the master page.
in the master page i go and look for the user entered from the query string at the DB and put the name after the hello or Guest if i get null.
this works fine.
now, in the child pages i also want to use this DB output , so i use session to store the DB entry for later use by the child.
my problem is that the child page's On_Load is performed prior to the Master page's On_Load and this causes the DB entry to be null before it was read by the Master page.
does anyone have any idea how to solve this problem ?
can i use the Page_Init in the master page for this ? is it acceptable and stable ?
tnx,
avi
modified on Wednesday, April 22, 2009 3:54 PM
|
|
|
|
|
Use the Mater Page's Page_Init event to run the code. That event fires before the child pages load event.
I didn't get any requirements for the signature
|
|
|
|
|
ok , tnx
|
|
|
|
|
How do I store a custom object in a ViewState. I know that viewstates do not support XmlSerialization. I currently have a class that is using XmlSerialization and all hell is breaking lose when trying to set a viewstate entry to that value.
|
|
|
|
|
ViewState is actually a name / value collection. You can't store a class in ViewState.
You can store a serializable object in Session though.
I didn't get any requirements for the signature
|
|
|
|
|
You can store an object inside a viewstate as long as it is BinaryFormat-able.
|
|
|
|
|
So is that what you are doing?
In my 8 years of doing asp.net I have never once tried to store an object in viewstate. Can ask why you want to store an object in viewstate?
I didn't get any requirements for the signature
|
|
|
|
|
I am trying to store the object in a control. What do you suggest?
|
|
|
|
|
Well, if you have a base page class or a master page. Store the object in session.
The reason for the base page class or master page is that you can check what aspx page is being loaded and set the session object to null if it is no longer needed. So it will behave like viewstate but you won't have all that data traveling back and forth to the client.
I didn't get any requirements for the signature
|
|
|
|
|
In the absence of a master page or base class you can also use the global.asax to manage the session objects.
|
|
|
|
|
Thanks for the tip, I never thought of that. Does the Application_BeginRequest event fire on every post back?
I didn't get any requirements for the signature
|
|
|
|
|
I think so but the way I usually do it is to wire up an event to page PreInit in Application_PreRequestHandlerExecute. It might not be the best way to do it (so I'm open to suggestions) but it works a treat.
|
|
|
|