jbisono 51 Posting Pro in Training

Try a Inner Join like this.

SELECT TABLE1.FIELD1, TABLE1.FIELD2
FROM TABLE1 INNER JOIN TABLE2 ON TABLE1.FIELD3 = TABLE2.FIELD3
WHERE TABLE2.FIELD4 BETWEEN 'A1' AND 'A50'
jbisono 51 Posting Pro in Training

We glad to hear that :)

jbisono 51 Posting Pro in Training

Oh ok good catch, i think by default that is true, right?

jbisono 51 Posting Pro in Training

I dont know if this might help you too, i sometimes has problem using dropdownlist.selectedValue; instead i use DropDownList.SelectedItem.Value, the last one seems to work right. as far as i know they both should do the same, but why one is working for me and the other one not, dont know yet.

regards

jbisono 51 Posting Pro in Training

Check the selectCommand in sqldatasource id "jobSqlDS" add "Distinct" in the select statement and give it a try.

jbisono 51 Posting Pro in Training

Ok in the SqlDataSource1 this part of it.
"ConnectionString="<%$ ConnectionStrings:ConnectionString %>""
basically its looking the web.config file in the section ConnectionString should be a connection called "ConnectionString".
verify if that is true.

jbisono 51 Posting Pro in Training

Maybe because you have two namespace that contains the same class name on it

using System.Net.Mail;
using System.Web.Mail;

I would try first taking out the second one because that one is obsolete, and give that a try.

jbisono 51 Posting Pro in Training

I Like momerath solution!!!

jbisono 51 Posting Pro in Training

Hi friends, can you guys help me to find the best way to track information changes in sql server 2000, like a free utility. The problem is that i need to track every single table because i want to figure something out. we have an ERP System and there is one process that i would like to know what tables it touch something like that.

thanks.

"sorry about the title"

jbisono 51 Posting Pro in Training

I think you are mixing two things here, i recommend you or you use javascript or c#, I see you have the selectedIndexChange method so your dropdownlist goes like this.

<asp:DropDownList ID="ddlType" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlType_SelectedIndexChanged" />

Now your page load is fine but within your selectedindexchanged method just do this

txtrate.Text = ddlType.SelectedItem.Value;

if you really need the javascript version let me know.

jbisono 51 Posting Pro in Training

In SQL SERVER I believe you can do this. so maybe that can help you to organize it in mysql it should be something similar to this.

SELECT CUSTOMERID
FROM TABLE
GROUP BY CUSTOMERID
HAVING COUNT(FLOWER) >= 2
jbisono 51 Posting Pro in Training

Ok let me give you an idea then. First of all its under a UpdatePanel, second I may say DropDown but i actually using the select control the classic one. if you did read my original post which i attached the link above, I have a treeview of parts like a bill of materials then in some parts i create a select control to show a multiple option of something. here is how i create a single node with a select control attached.

TreeNode tn = new TreeNode();
//Start building the select control
StringBuilder option = new StringBuilder("<option value=''></option>");
//this check if there is more than one option to insert into the select control
if (partid.Field<string>("BUILD_OPT").IndexOf("-") > 0)
{
   foreach (string st in partid.Field<string>("BUILD_OPT").Split('-'))
   {
      option.Append("<option value= '" + st + "'>" + st + "</option>");
   }
}
else
{
   option.Append("<option value='" + partid.Field<string>("BUILD_OPT") + "'>" +   partid.Field<string>("BUILD_OPT") + "</option>");
}
//this is actually what the node text contains. the variable z is just an autoincrement integer that i have in my code.
tn.Text = "<span class='pchange'>" + partid.Field<string>("PART_ID") + (string.IsNullOrEmpty(partid.Field<string>("ENG_ID")) ? "" : "/" + partid.Field<string>("ENG_ID") + "") + "</span>/<select id='D" + z.ToString() + "' class='DLean' name='D" + z.ToString() + "'>" + option.ToString() + "</select>";

now this will show something like

partNo-Pur-SelectControlHere

Like i said in my first statement Internet Explorer i have no problem, In firefox when i click the select control to select another option a postback is trigger. Does anyone knows why could be …

jbisono 51 Posting Pro in Training

Hi all. originally i have this problem http://www.daniweb.com/forums/thread283467.html everything works good in IE but in firefox if i try to change the dropdownlist attach to the node in the treeview it seems like at the moment i click the dropdownlist a postback is trigger and dropdownlist go back to the original index selection which is index 0 no data selected. how to avoid this.

thanks for any help.

jbisono 51 Posting Pro in Training

Hi all. originally i have this problem http://www.daniweb.com/forums/thread283467.html then i start this post everything works good in IE but in mozilla if i try to change the dropdownlist attach to the node in the treeview it seems like the at the moment i click the dropdownlist a postback is trigger how to avoid this. maybe i should open a new thread for this?

thanks for any help.

jbisono 51 Posting Pro in Training

try two things.
first: try to make the id parameter in the same manner as the others.
second: instead of using the ExecuteReader method use ExecuteNonQuery method. that returns the number of rows affected by the query.

regards.

jbisono 51 Posting Pro in Training

A friend of daniweb give out a good solution.

in this post there are two solutions for it. the first one should work if you have MSSQL 2005 and above, the last solution will work no matter what version you have. I hope that help you.

jbisono 51 Posting Pro in Training

this is how i loaded it up.

rpt.Load(Server.MapPath("~/reports/myreport.rpt"));

all my reports are under a folder called reports.
hope that help.

jbisono 51 Posting Pro in Training

Can you show your code, so we can see exactly where are you stuck?

jbisono 51 Posting Pro in Training

try to use the SingeOrDefault method. like

Dim owing = (From accounts In db.Accounts Where accounts.CustNumber Is current Select accounts.AmountOwing).SingeOrDefault()
jbisono 51 Posting Pro in Training

Ok. definitely was a parameter problem. thanks adatapost.

jbisono 51 Posting Pro in Training

Maybe this can help you, I am working in an intranet site and everytime i need to send something i create this static function to do it.
using System.Net.Mail;

public static string SendEmail(string sender, string recipient, string subject, string body)
{

   MailMessage email = new MailMessage();
   MailAddress froma = new MailAddress(sender);
   email.From = froma;
   email.To.Add(recipient);
   email.Subject = subject;
   email.IsBodyHtml = true; //just in case you want to send as html if it is regular text then false.
   email.Body = body;
   SmtpClient smtout = new SmtpClient("yoursmtpserver");
   try
   {
      smtout.Send(email);
      return "Email sent successfully";
   }
   catch (SmtpException ex)
   {
      return ex.Message;
   }
}
jbisono 51 Posting Pro in Training

Hi all, i have a little problem here trying to print a crystal report document using the PrintToPrinter method. This process is trigger by the event click in a asp:button control, basically i just saying this.

rpt.PrintOptions.PrinterName = @"PathToPrinter";
rpt.PrintToPrinter(1, false, 0, 0);

this solution works fine if the report does not have any parameter, once a report has one or more parameters i have this error "System.Runtime.InteropServices.COMException: Missing parameter values."

I also tried to add the parameters again to the report so that my code lookslike this

Add parameters in here

rpt.PrintOptions.PrinterName = @"PathToPrinter";
rpt.PrintToPrinter(1, false, 0, 0);

Same error.

If someone can provide me any idea what am i missing, i will really appreciate it. thanks for reading.

jbisono 51 Posting Pro in Training

are you using sqldatasource controls to bind the detailsview? if that is the case just replace the textfields for dropdownlist, create to sqldatasource one for the doctor table, and the other one for patient. then your dropdownlist you bind it like this.

<asp:DropDownList ID="ddlDoctor" runnat="server" DataSourceID="YourSqlDataSourceForDoctor" DataTextField="NameOfDoctorField" DataValueField="DoctorIDField" SelectedValue='<%# Eval("DoctorIdFromConsultationTable") %>'></asp:DropDownList>
jbisono 51 Posting Pro in Training

Is this C# or Visual Basic? second if you have separate table for doctor and patient in the consultation table you do not need to add gpname, patientfirstname, patientlastname instead you save the id for both so you table for consultation will end like ConsultationId, DoctorId, PatientId, Height, etc.

I understand the Height and weight put it on the consultation table because that can change over the time, i will help you but first i would like to help you normalize your database a little bit more.

another thing is do you want to show all patient always or all patient that belongs to a particular doctor?

regards

jbisono 51 Posting Pro in Training

Hi in this post there are two solutions for it. the first one should work if you have MSSQL 2005 and above, the last solution will work no matter what version you have. I hope that help you.

jbisono 51 Posting Pro in Training

blackdragon i rather he explain over here so we can all see the solution.

jbisono 51 Posting Pro in Training

maybe this is what you are looking for

Request.ServerVariables["LOGON_USER"].ToString()

jbisono 51 Posting Pro in Training

That can be done using threading, which indeed is a very deep topic but basically you can do this.

System.Threading.Thread tre =  new System.Threading.Thread(new ThreadStart(MyFunction));
tre.Start();
System.Threading.Thread.Sleep(10000);
if (tre.IsAlive)
   tre.Abort();

//The you have your function
void MyFunction()
{
   //Do process
}

There is a lot of things you can do with thread, delegates, async calls etc, read about it. hope that help you to go and the right direction

jbisono 51 Posting Pro in Training

Ok cool.

jbisono 51 Posting Pro in Training

well i found the problem, the hovermenuextender is the culprit.

<asp:Panel ID="pnlTest" runat="server" style="display:none">
   <asp:LinkButton ID="lnkDeletePrinted" runat="server" Text="Delete Print date"></asp:LinkButton>
</asp:Panel>
<cc1:HoverMenuExtender ID="HoverMenuExtender1" runat="server" TargetControlID="lblPrintedDate" PopupControlID="pnlTest" OffsetX="5" OffsetY="15" >
</cc1:HoverMenuExtender>

My code does not like this. i took that out in it work beautiful any idea how can i make it work?

jbisono 51 Posting Pro in Training

sorry about that.

mean clear the rows in the gridview. I am using this.

GridView1.DataSource = null;
GridView1.DataBind();
jbisono 51 Posting Pro in Training

I have a GridView inside an UpdatePanel set to conditional update mode and ChildrenAsTrigger to false, now the gridview got bind successfully, we are talking about 500 rows, i have others gridview but in different UpdatePanel. Everything works except when i try to clear everything, it hangs saying this: "A script on this page may be busy, or it may have stopped responding. You can stop the script now, or you can continue to see if the script will complete
" whether i select stop script or not it keep going without end.

When i load jobs with, lets say 50 rows, the clear process its done successfully.
I would like to hear some feedback about, any idea ill thanks so much. i test every single gridview separate, and no problem.

this is the gridview structure just in case it help

<asp:GridView ID="gvPlanning" runat="server" SkinID="gridviewSkin" AutoGenerateColumns="false" OnRowCommand="OnRowCommand_Trigger" OnRowDataBound="gvPlanning_OnRowDataBound" >
   <Columns>
      <asp:BoundField DataField="DemandBaseId" HeaderText="Demand" ReadOnly="true" />
      <asp:BoundField DataField="DemandSeqNo" HeaderText="Dmd. No." ReadOnly="true" ItemStyle-Width="15" />
      <asp:BoundField DataField="DemandLotId" HeaderText="Dmd. Lot" />
      <asp:BoundField DataField="DemandQty" HeaderText="Dmd. Qty" />
      <asp:BoundField DataField="BaseId" HeaderText="Supply" ReadOnly="true" />
      <asp:BoundField DataField="LotId" HeaderText="Lot Id" ReadOnly="true" />
      <asp:BoundField DataField="PartId" HeaderText="Part" ReadOnly="true" />
      <asp:BoundField DataField="QtyHand" HeaderText="Qty on hand" ReadOnly="true" />
      <asp:TemplateField HeaderText="Sply. qty">
         <ItemTemplate>
            <asp:TextBox ID="txtUDesiredQty" runat="server" Text='<%#Bind("DesiredQty") %>' CssClass="ShortTextBox"></asp:TextBox>
            <asp:HiddenField ID="hfDesiredQty" runat="server" Value='<%#Bind("DesiredQty") %>' />
            <asp:HiddenField ID="hfSupplyType" runat="server" Value='<%#Bind("LinkType") %>' />
            <asp:HiddenField ID="hfWoStatus" runat="server" Value='<%#Eval("Status") %>' />
         </ItemTemplate>
      </asp:TemplateField>
      <asp:TemplateField HeaderText="Prnt. date">
         <ItemTemplate>
            <asp:Label ID="lblPrintedDate" runat="server" Text='<%#Bind("PrintedDate") %>'></asp:Label>
            <asp:Panel ID="pnlTest" runat="server" style="display:none">
                <asp:LinkButton ID="lnkDeletePrinted" runat="server" Text="Delete Print date" CommandName="DeletePrintDate"></asp:LinkButton>
             </asp:Panel> …
jbisono 51 Posting Pro in Training

Is that a web application or desktop app? because i think that is the default behavior of desktop app.

jbisono 51 Posting Pro in Training

well remember that the avg function it will find the avg by rows because how many rows its hard to know, but if you want the avg for multiple columns and a specific row, its more straightforward because you know how many columns are so you will end up with something like.

SELECT NAME, ((SCORE1 + SCORE2 + SCORE3) / 3) AS AVERAGE
FROM TABLE1
jbisono 51 Posting Pro in Training

Well i did what you said, load the data in cache, work with it and then delete it and when down from around 5 minutes to 1:30 min.

about your last post i am the owner/develop of this application but not the database structure i mean in part, that database is for a ERP System that we have im just building separate tools to accomplish specifics tasks, so about the database structure i cannot do too much, but let me tell you, i am most happy now.

thanks.

I think the bottom line is, never do multiple request to sql server, no matter how big is your result set bring the data to cache and get what you want, get rid of the rest.

jbisono 51 Posting Pro in Training

The thing is that the AVG Function is an aggregate one, so that usually means that you have to group by so your statement will end something like this.

SELECT NAME, AVG(SCORE1 + SCORE2 + SCORE3) AS AVERAGE
FROM TABLE1
GROUP BY NAME
jbisono 51 Posting Pro in Training

Lets say what im trying to do is once i have a customer order for a particular part. i have to find the demand and supplies in order to build that part, and the way the database is structure i believe making a recursive function is my best shot. the fact that we have SQL 2000 does not support CTE.

jbisono 51 Posting Pro in Training

Oh my bad, did not realize that!!!, but are you still having problem?

jbisono 51 Posting Pro in Training

If you have 3 tables with over 10,000 records each and you have to build a recursive function with this 3 tables link, and you expect to have in return around 200 records, What will you do? "The website is intranet host"

Query the sql server multiple times or load the whole data once and play only at the web server level. "Any other suggestion".

The Sql server is a very high performance machine but the web server is not.

What is the best way to go?

jbisono 51 Posting Pro in Training

I think you can do this.
in your aspx page.

<asp:FormView ID="fvTest" runat="server" AllowPaging="true" OnPageIndexChanging="fvTest_PageChange">
   <ItemTemplate>
      <asp:TextBox ID="txt1" runat="server" Text='<%#Eval("id") %>'></asp:TextBox>
      <asp:TextBox ID="txt2" runat="server" Text='<%#Eval("part") %>'></asp:TextBox>
      <asp:TextBox ID="txt3" runat="server" Text='<%#Eval("rev") %>'></asp:TextBox>
</ItemTemplate>
</asp:FormView>

in the page source
call the BindForm() method in the page load or any other place you want.

private void BindForm()
{
   DemandSupplyLinkDataContext db = new DemandSupplyLinkDataContext();
   var x = from y in db.CUST_ORDER_LINEs
      select new
      {
         id = y.CUST_ORDER_ID,
         part = y.CUSTOMER_PART_ID,
         rev = y.DRAWING_REV_NO
      };
   fvTest.DataSource = x;
   fvTest.DataBind();
}

protected void fvTest_PageChange(object sender, FormViewPageEventArgs e)
{
   fvTest.PageIndex = e.NewPageIndex;
   BindForm();
}

if you use a linqdatasource object and bind the formview with it, i think you dont need to create the pageindexchange method.

jbisono 51 Posting Pro in Training

Do you mean if num is decimal? in that case you can overload the function.

jbisono 51 Posting Pro in Training

You are totally right Lusiphur. Thanks for correcting me. Roses89 if you need help to complete the code let us know.

jbisono 51 Posting Pro in Training

Try to calculate that at the database level, and return the total with your result. your statement should looks like

SELECT NAME, SCORE1, SCORE2, SCORE3, SCORE1 + SCORE2 + SCORE3 AS TOTAL
FROM YOURTABLE
Lusiphur commented: Excellent Recommendation :) +1
jbisono 51 Posting Pro in Training

What control do you want to render the age in?

jbisono 51 Posting Pro in Training

like our friend tesuji said

SELECT userid, count(positionid) AS cntpos FROM yourtable
   GROUP BY userid
   HAVING count(positionid) > 1;

that should work

jbisono 51 Posting Pro in Training

Lets say that your DOB is being display by a textbox id = "txtDOB" then you can do this.

int years = DateTime.Today.Year - Convert.ToDateTime(txtDOB.Text).Year;
jbisono 51 Posting Pro in Training

tesuji is right but you should not group by the positionid also.

jbisono 51 Posting Pro in Training

That looks good. Just a few things to check out.

1 - The Connection String is recommended to keep it in one place, like the web.config if you are in web development or some ini file.

2 - The ExecuteNonQuery() method is a really common use one. So if you can create a separate class and create a function to receive the string query and the connection(the last parameter only need it if you deal with different database), return an integer. this help to avoid repeating code.

3 - this is just a recommendation, something different, check "LINQ" .

jbisono 51 Posting Pro in Training

well men i do not want make you feel bad either, i know is not easy at the beginning thats why we have to read a lot. and maybe linq is not the best option to start but with reading a little bit, i bet you anyone can get somereal work done, and almost all the tutorial explain everything where thins comes from. anyway here some links that can help you.

http://weblogs.asp.net/scottgu/archive/2007/05/19/using-linq-to-sql-part-1.aspx
http://www.hookedonlinq.com/LINQtoSQL5MinuteOverview.ashx
http://msdn.microsoft.com/en-us/vcsharp/aa336746.aspx

the northwind database you can download it from microsoft website.

nick.crane commented: Nice LINQ links, thanks +1
jbisono 51 Posting Pro in Training

Well i think I am with nick.crane you should create like a book store yourself put some table that then you can query by category, author, language, country etc. and start playing making updates etc. and then come up with more specific questions. some people like to see some real productivity soon, if that is your case i recommend you using LINQ. there is some tool that generate classes for you base on your database, and you can get some real code fast and good.

but it is always nice to see how everything works in details.