agrothe 26 Junior Poster

Ok, still not 100% sure what you are trying to accomplish, but I do know that the biggest issue is the way you are looping with the data reader.

I've taken your original code and converted to a datatable and it outputs the following in the richtextbox1: Section: 32 Measurdate 7/20/2010 12:00:00 AM Here is the modified code with a datatable you can actually use to loop with:

int[] fj1Sections = {1,35,33,32,20,19,17,16,18};
            bool test = true;
            string connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=car_mos.accdb;Persist Security Info=False";
            string queryString =
                "SELECT dbo_SectionMeasure.[BakingFurnaceNo], dbo_SectionMeasure.[SectionNo], dbo_SectionMeasure.[MeasureDate], dbo_SectionMeasure.[IsLastValue] FROM dbo_SectionMeasure ORDER BY dbo_SectionMeasure.[MeasureDate] DESC;";
            OleDbConnection connection = new OleDbConnection(connectionString);
            connection.Open();
            OleDbCommand command = new OleDbCommand(queryString, connection);
            DataTable dt = new DataTable();
            dt.Load(command.ExecuteReader());

            try
                {

                    OleDbDataReader reader = command.ExecuteReader();
                    
                    for (int i = 0; i < fj1Sections.Count() ; i++)
                    {
                        for(int x=0;x<dt.Rows.Count;x++)
                        {
                            string section_no = dt.Rows[x][1].ToString();
                            if ((section_no == fj1Sections[i].ToString()))
                            {
                                //result;

                                richTextBox1.Text = "Section: " + fj1Sections[i].ToString() + "       Measurdate " + dt.Rows[x][2].ToString();
                            }
 
                        }
                    }
                }
                catch (Exception ee)
                {
                    richTextBox1.Text = ee.ToString();
                    
                }

I'm sure there is a more efficient way to do this, but hopefully this gets you going!

See more on the DataTable usage here

agrothe 26 Junior Poster

OK, so let me get this straight:

If you have the following:

1       35        1/1/2009        true
1       35        1/1/2011        true
1       16        1/1/2009        true
1       16        1/1/2011        true

You want to get rows 1 and 3 correct? The oldest date for 35 and oldest date for 16, right?

agrothe 26 Junior Poster

Ok, I understand a bit more now after running your code.

You are looping over each of the number in your list AND looping through your records.

It's not working because the while(reader.read()) does not reset each loop. The .read() function is forward only. See this MSDN article on the class.

I hope this helps. Try populating a dataset, then you can using it multiple times.

agrothe 26 Junior Poster

Why the for loop? The while loop goes through all the rows.

agrothe 26 Junior Poster

Not sure if I understand you right. Can you give me a few examples database rows and what outcome you want?

Given database rows:

ID        Num        Date
1         34         1/16/2011
2         34         2/5/2011
3         13         5/5/2011

I'm assuming that when you Choose "34" in your dropdown, you want to get the oldest date, in this case, 1/16/2011.

Is that right? If so, my previous query does the trick. If not, we need to further refine.

agrothe 26 Junior Poster

Why don't you use a SQL Statement instead? If you only need one record (oldest date) then it isn't efficient to bring back all records from the database.

Amend your query to something,

SELECT TOP 1 [fieldname], [etc...], FROM tablename WHERE [column2] = '<listvalue>' ORDER BY [datefield]

That will give you one row with the oldest date where the column2 is equal to the value in your ComboBox.

Note: Highly recommended to use a parameterized query and not just concatenate the string, but this is just the sql example.

This reduces network traffic and greatly enhances your response time.

agrothe 26 Junior Poster

Hmm, off the top of my head, name is depreciated. What browser are you trying? Swap out "name" for "id".

Also, try

onclick="return clearVillage();"

Some browsers, (IE usually), likes the return keyword at times.

Also,

Check to ensure the button isn't calling the function before the function is declared. (i.e. is the function declared in the <head> tag?)

agrothe 26 Junior Poster

Try setting a css class to that column and setting the css style "visibility:hidden;". This way asp can still access the data but the user won't see it.

If the data is confidential then your best bet is to pull the data from DB on post back and work with it there.

agrothe 26 Junior Poster

Here try this: (sample VS 2010 project attached.)

webBrowser1.Navigate(textBox1.Text);

                if(webBrowser1.EncryptionLevel != WebBrowserEncryptionLevel.Insecure)
                    label1.BackColor = Color.Green;
                else
                    label1.BackColor = Color.White;

EDIT:
You'll need to check for mixed authentication mode as well but this should get you on the right track.

agrothe 26 Junior Poster

What objects are you using for web browsing? The built in .NET browser? Try pasting in the code where you are trying to accomplish this.

agrothe 26 Junior Poster

Oh, your writing a browser. That wasn't clear to me, Sorry.

Use something like:

HttpRequest request = application.Request;
if (request.IsSecureConnection)
{
     //do something
}
agrothe 26 Junior Poster

Exactly. If you want that to "Turn Green" you need an SSL certificate installed. You need to purchase one and have it installed your web server.

agrothe 26 Junior Poster

Where is it hosted? You usually have to order a Certificate from a provider like RapidSSL, GoDaddy, Geotrust, etc.

The process will involve a bit of back and forth from your hosting provider unless you manager your own server.

Some shared hosting accounts provide a free shared SSL, but that changes your URL from yourdomain.com to yourdomain.hostingdomain.com.

$50(ish) per year gets you a cert at GoDaddy.

agrothe 26 Junior Poster

use the split function using : as your find character.

Then, using your array set your textboxes = to the proper indices.

textbox.text = myarray(1) etc.

myarray(0) will hold the text "dispframe" and you should probably drop the leading :

Make sense?

agrothe 26 Junior Poster

well, the problem was
i was suppose to write it as

RsObj.AddNew
RsObj.Fields("fname")="aashish"
RsObj.Fields("lname")="n"
RsObj.Update

Thank's agrothe , for all the help...............

You're welcome! Your previous use of addnew was suspect to say the least! I'm glad your up and running again.

I would now suggest you start using parametrized queries. The method you are using now is very susceptible to SQL Injection Attacks, which I've experience first hand :) .

The provided link is from 4guysfromrolla website and is an excellent way to update your database (very simple) and provides much greater security.

Cheers.

PS: please mark the thread as solved.

agrothe 26 Junior Poster

Can you please verify the exact line and highlight it? I havn't see the addnew method used like that before, not saying it won't work, but just to make sure.

aashishn86 commented: you were right... it doesn't work this way :) +1
agrothe 26 Junior Poster

Try setting the activeconnection first:

set comm=Server.CreateObject("ADODB.Command")
comm.ActiveConnection=conn
agrothe 26 Junior Poster

hey thank's..... i tried that too...
but it still gives the same error...

I usually just use:

rstest.Open "tablename", constr, 2, 2
agrothe 26 Junior Poster

You don't give us much to go on here. Do you have a sample page, or a link to the control page?

Typically javascript like so will work:

var txtValue = document.getElementById('idoftextbox').value;

If that's not clear, post some more details.

agrothe 26 Junior Poster
rstest.Open "test", constr, adOpenDynamic, adLockOptimistic, adCommandTableDirect

aashishn86, you cannot use named parameters without first declaring them.

Try

rstest.Open "test", constr, 2, 3, 512

See here for more numeric values.

Alternatively, you can declare the variables first. like so:

DIM adOpenDynamic, adLockOptimistic, adCommandTableDirect
adOpenDynamic = 2
adLockOptimistic = 3
adCommandTableDirect = 512

Then you can use the named arguments in your open stmt.

agrothe 26 Junior Poster
<% 
   comobj.CommandType =  adCmdTable
%>

You don't have adCmdTable defined. ASP doesn't have the built in definitions as does VB. You need to declare it first.

do this before you set the commandtype:

dim adCmdTable
adCmdTable = 2

And visit here for more technical details on the ADODB Command object.

agrothe 26 Junior Poster

thank u for reply
so i think if site is not on my computer
i just hired space and domain
i must call the company i hired from
and tell them to do as u told

is that no other way because they are with very slow response?!?!?

Most hosts support uploading your own 404.asp and check there first by default. Also, try this page for more information.

agrothe 26 Junior Poster

To build on what the previous two posters said, you basically want to use your textbox as a variable.

So in the on_click code of your command button put something like:

Form1.recordsource = "select * from tablename where columname like '" & textbox1.value & "*';"
form1.requery

This will change the underlying record source of your form based on the text in your text box.

You can actually get a nice filter going with several options via combo boxes and list boxes using this technique. I've got a working sample somewhere of about 6 options to filter a query based form somewhere.

Don't forget to check to make sure there is actually a value in the text box first.

agrothe 26 Junior Poster

There is a program called EasyRecover which I have used in the past. It's really good. However, if in restoring you computer you wrote over the areas which your program was on your hard drive, its probably gone for good. Try running the recover software on your thumb drive too.

agrothe 26 Junior Poster

I'm new to VB so my question is probably very simple. anyway here it is..

I want to make a side bar showing one form that is like a sidebar in a web page such as on the left side of the MDI form. Which holds the programs main functions .. Then once a button is pressed on that form, I want it to show the form that performs that action in the right pane. Without just popping up . I've tried setting the left property of the window popping up and the dimensions larger than the screen but it doesn't work , and when I set it to maximize on start, then it covers the left frame.

Any help appreciated.

Sound like you need to add an image control to your MDI form. It will snap to either side or to top or bottom. Then you can add buttons, combo's and other controls to the image control. Or was it a picture control? Image or picture, only one will work, but that sounds like your solution.

Also, forms will automatically see the edge of your image control as the edge of the mdi form, so scroll bars will appear properly if the form goes behind the image control so users and scroll over to see it.

Comatose commented: Nice Job On This One +5
jonc commented: Superb, I was looking for an idea on making a sidebar - that's cleared it all up. Thanks! +2
agrothe 26 Junior Poster

I don't see the problem.... VB is reading data from the serial port right? So should it matter if the form's .visible property is true or false?

I wonder is it possible the application doesn't have a proper hook on the serial port? Is a third party control being used or windows API?

agrothe 26 Junior Poster

how do i add the numbers in a listbox and display it in another textbox?

Create new project, add list1 and txtText1 to the form1 and paste:

Option Explicit

Private Sub Form_Load()
    Dim x As Integer
    Dim inx As Integer 'counter
    
    List1.AddItem "1"
    List1.AddItem "2"
    
    For inx = 0 To List1.ListCount - 1
        x = x + CInt(List1.List(inx))
    Next
    txtText1.Text = x
    
End Sub
agrothe 26 Junior Poster

Sure.

Create a new project, add an MDI form and 2 or more MDI Child forms.

in the MDI Form code window paste:

Private Sub MDIForm_Click()
MsgBox Me.ActiveForm.Caption
End Sub

Click on the MDI form to see which child form is currently active. The .ActiveForm property gives you complete access to the current active MDI Child. For example: .hide .show .caption .width .height etc...

agrothe 26 Junior Poster

Declare your variables at the form level, if you declare in the procedural level, they get reset each time the sub or function runs.

agrothe 26 Junior Poster

Yup, that's write... do me a favor and toss in some code tags ;)

write or right?? LOL code tags it is . . .

agrothe 26 Junior Poster

Sounds like you need to take code out of the same table as category, might help make the system more usable.

agrothe 26 Junior Poster

I think you have to manipulate the printer object directly.....

This is correct. Use:

Printer.Orientation = 2
Form1.PrintForm

1 for Portrait and 2 for Landscape.