savedlema 17 Junior Poster

Reverend, do you have an idea with this:

'sqlQuery = "SELECT ROW_NUMBER () OVER (ORDER BY Average desc) AS Rank,StudentId as rollNO,Physics,Chemistry FROM tblForm1 "

It is bringing an error message: "Syntax error (missing operator) in query expression 'ROW_NUMBER() OVER (ORDER BY StudentMarks desc)'."

I wonder if someone out there can fix that.

savedlema 17 Junior Poster

Thanks Reverend!
Look, I can perform a SELECT...ORDER BY that can fill the dataset and then the datagrid view like I did to the gridview whose image I have attached here:
resuls

As you can see, G1 will be number 1 student (ranking), G2=2,G5=5 and G3=4. My problem is, to be able to get the rank number for a particular student (so that I can include it in a student report), for example, get rank=3 for G5 student. From the datagrid I have now, I will have to manually count to tell the student's rank in the class, this is tedious when there are many students in the class.

I wish the rows in the dataset were numbered, then I could get the rank number from there. Any suggestion on how to do this?

Thanks again.

savedlema 17 Junior Poster

Thanks Reverend.
I use Access database (.mdb),For this case,

I have tables for each subject i.e tblPhysics,tblChemistry,tblBiology.. (tables contain StudentID,Test,Final,Total,Average,Grade). From the form (frmScores), I can record student marks for test and final, calculate total and average and determine the grade (A,B,C,D..), and post these values to a table for a specific subject (whethere its tblPhysics,tblBiology or what)

When I came to ranking students, I thought the best approach would be to post the total marks from the frmScores form to another table tblClass1 which will contain total subject marks for each student, so the table will look like this:
tblClass1 (StudentID,Physics,Chemistry,Biology,English....), in this table, I will store subject marks (integers) for each subject per each student (StudentID).

So then, I want to be able to sum up scores for each student, then compare the sum with other students in this table and determine the ranking.
Or, is there any other easy way for me to do this?
I hope I'm clearer.

Thanks for any inputs.

savedlema 17 Junior Poster

You can go here:http://www.ehow.com/how_4590003_program-timer-control-vbnet.html to get a start, and you can also Google for that and read. When you start working with the timer and face any problems, I think that is when you should ask here at Daniweb.
Happy programming!

savedlema 17 Junior Poster

I use Access. What difference will it make to the code I reported half-working?
Thanks.

savedlema 17 Junior Poster

Hi friends, thanks all for your contributions here at DaniWeb Community.
I want to ask one thing; I have a table where I keep values for students marks (StudentID,Marks). Let's say there are 50 students. I want to be able to display on the form the class rank for each student (who is 1st,2nd,3r.....50th) according the marks.

MY IDEA: If I load these marks & studentID to a dataset by using a SELECT statement with ORDER BY (or what?), I hope the marks will be listed in an Ascending/Descending order, so the first at the top, the last at the bottom. If that's correct, then can I obtain the student rank by obtaining his row number in the dataset?
For example, in

dataset.Tables("StudentRank").Rows (4).Item (2)

This will be for a student in rank/position 5 from the top. Now, how can I get the value contained in .Rows (4) and post it somewhere or use it anywhere?

I hope I explained myself well.

I will apreciate any help please.

savedlema 17 Junior Poster

Hi Amr, this one works:

        sqlQuery = "INSERT INTO tblPhysics1 (studentID)" _
                + "SELECT (studentID) FROM tblDetails WHERE Class = '1'"

But it does not regard the primary key violation. That's, if I execute the command the second time, it will still attempt to enter the data. I'm gonna try to catch this. Thanks, and pls let me know if you get the fix for 'NULL' and 'ISNULL'

savedlema 17 Junior Poster

Thanks again Amr!
I tried this :

        sqlQuery = "INSERT INTO tblPhysics (studentID)" _
                + "SELECT ISNULL(studentID, NULL) FROM tblDetails WHERE Class = 1"

        cmd = New OleDbCommand(sqlQuery, con)
        cmd.ExecuteNonQuery()

And got "Wrong number of arguments used with function in query expression 'ISNULL(studentID, NULL)'." Error message. Since I talked about the arguments..I removed ('NULL) and tried:

sqlQuery = "INSERT INTO tblPhysics1 (studentID)" _
                + "SELECT ISNULL(studentID) FROM tblDetails WHERE Class = '1'" //(note the '' in 1)

and got "You cannot add or change a record because a related record is required in table 'tblDetails'." Error message. Now I think the insert is okay, but there is something wrong with the StudentID (probably to do with a relationship btn the tables?), or may be its because I removed the 'NULL' and thus allowing it to insert a blank value for studentID (which is a primary key and wont allow blanks?)

Any advice?

Thank you so far.

savedlema 17 Junior Poster

Thanks Amr,
I tried to do this with your code:

    databaseSettings()
    con.Open()
    sqlQuery = "IF(SELECT studentID FROM tblDetails WHERE Class = 1) IS NOT NULL " _
                + "INSERT INTO tblPhysics (studentID) " _
                + " SELECT studentID FROM tblDetails WHERE Class = '1' "

    cmd = New OleDbCommand(sqlQuery, con)
    cmd.ExecuteNonQuery()
    MsgBox(" succesfully", vbInformation)
    con.Close()

But, ended up with the following error: Invalid SQL statement; expected 'DELETE', 'INSERT', 'PROCEDURE', 'SELECT', or 'UPDATE'.

Any ideas?

savedlema 17 Junior Poster

Hi! I want to move on from programming with Access database to MySQL. So I downloaded MySQL Workbenc 5.2CE from here, Installed it and I made my way into even creating a database and a table in it. I just want to know, will it be any different to connect to this Workbench than databases made with previous versions of MySQL? Are the procedures (codes) going to be similar? This version looks like its difference from what I have been reading from tutorials around.

I will appreciate any guidance.

savedlema 17 Junior Poster

Hi all! I think I need some help moving data from one table to another. Here is the scenario:
I have two tables, tblDetails (studentID,Name, Class.....) and tblPhysics (StudentID.....). Now, I want to SELECT StudentID from tblDetails WHERE Class = 1 (SELECT tblDetails.StudentID FROM tblDetails WHERE tblDetails.Class = '1') So this one I can do. But then, I want to INSERT the results of the above query into a table tblPhysics which has a column StudentID. How do I do this? Select values from one table and then insert them to another existing table. Please note that I want to insert the query results to an existing table (I tried to use SELECT INTO, but that will create a new table).

I will appreciate any help.
Thanks.

savedlema 17 Junior Poster

What error msg do you get?

savedlema 17 Junior Poster

Hi friends!
I got an ePad (Model : zte180, Adroid 2.2) device. I want to connect an USB Modem (Airtel) so that I can use it to connect to the internet. I followed the following procedures:
go to settings-->Wireless&Network--->Mobile networks --->Access Point Name --->Add new access point.

Now, the problem comes with adding a new access point. My ePad is requesting for MNC and MCC values, which I don't know, I also went to my cellular company officess (Airtel) they also can't know the values for MNC and MCC. So we tried filling anything, like 123 in MCC and MNC. Then I saved the APN. But even after that, I can't get to the internet.After rebooting, when I navigate to Access Point Name, I can't even see the APN I had created and saved. I'm a computing guy but quite new to ePad/Android.
Can someone help please?

With thanks,
Frank.

savedlema 17 Junior Poster

I didn't know that, but I have learnt my lesson in a hard way! Well, at least now I know!
And, what are other reserved keywords? It'll be good to know them.

Again, Thanks Reverend for you continued support here.
Shalom!

savedlema 17 Junior Poster

Reverend Jim,
Thank you so much for your continued support. I have one thing to my amazement.You know I tried so many codes for the same INSERT but it never worked. But, I went to my database, changed the name for the password field to anything like "SecretWord" and it works!. There is no problem with "Username", but if I rename it to password again, there is an INSERT Syntax error. Change it back to "SecretWord" and it works just fine. Now, I don't know why and I wonder if anyone can reason this.
I'm okay now. Thanks, and many thanks to the Dani Web community.
Shalom!

savedlema 17 Junior Poster

Reverend Jim, thank you for that alert. But, its not the case with me. The data I tried to test entering are Frank for username and shalom for password. Anything else? But,Thank you.

Jireh, thank you for your response. But I don't use an SQL server, I use Access database.

I'm still trying.

savedlema 17 Junior Poster

Hi friends!
I have a piece of code that I think should be working just fine, but I wonder why it doesn't work, and I get an "Syntax Error in INSERT statement" error message.
Here is the code to affect a table called "Users" in my Access database.

            Dim cmd As OleDb.OleDbCommand
            Dim sSQL As String

            con.Open()
            sSQL = "INSERT INTO Users (Username, Password) " _
                   + "VALUES ('" & Trim(Me.txtUser1.Text) & "', '" & Trim(Me.txtPass1.Text) & "') "

            cmd = New OleDb.OleDbCommand
            With cmd
                .CommandType = CommandType.Text
                .CommandText = sSQL
                .Connection = con
            End With
            cmd.ExecuteNonQuery()

            MsgBox("information updated succesfully", vbInformation)
            con.Close()

Thanks all.

savedlema 17 Junior Poster

I think one approach is setting a group policy affecting that user, that will limit user's download to 10MB (there is one, just set it). What server are you using? 2006??? Give details.

savedlema 17 Junior Poster

Hi friends!
I'm looking for an easy way to enable a user of my app to print the contet of a GridView.However, I think an easy way will be to convert it into a Crystal Report or pdf (many people say to pdf is terrible), so, I'd like to convert it into a Cyrstal Report (or just a report). Some people have talked about converting a GridView into a Crystal Report, but none have I seen talking about this when I generated my GridView in codes. I mean, people will talk of creating the dataset and data adapter using the GUI in VS2010, but I created mine in codes. Also, when telling the CR where to get its data, people talk about dragging the data connections (table fields etc) to the report in a GUI way, but I can't see how to do that in codes. I use codes for dataset and data adapter in my application forms, how can I code the Crystal Report?

=========== My codes please ==========

    'database
    dbProvider = "PROVIDER= Microsoft.Jet.OLEDB.4.0;"
    dbSource = "Data Source = data/Human Resource.mdb;"

    con.ConnectionString = dbProvider & dbSource

    'Search for Department

    If rdDept.Checked = True Then

        ds.Tables.Clear()
        con.Open()
        sqlRadio = "SELECT ID,FirstName,MiddleName,Surname,Phone,Birthday,Empl_Year,Department,Residence,Status " _
        + "FROM tblDetails" _
        + " WHERE Department = '" & Trim(Me.txtSearch.Text) & "'"

        da = New OleDb.OleDbDataAdapter(sqlRadio, con)
        da.Fill(ds, "HumanResource")
        con.Close()

        'Fill the data grid
        dgv1.DataSource = ds.Tables("HumanResource")

        'If nothing was found
        If ds.Tables("HumanResource").Rows.Count = 0 Then
            MsgBox("No any record found matching your …
savedlema 17 Junior Poster

Hi Waddell, your post has been very helpfull to me. Thank you very much for responding, and thank you for taking your time to type all that code for me.
Thank you all.

savedlema 17 Junior Poster

Hi friends,
I'm developing an application for HR. I have two tables so far.One is tblDetails and the other is Academic. I have created a relationship (ID to AcademicID), I have been able to pull data to a form by this SELECT statement:

 sqlSearch = "SELECT tblDetails.ID, tblDetails.FirstName, tblDetails.Surname, Academic.AcademicID, Academic.FirstLevel, Academic.FirstAward, Academic.PlaceFirst, Academic.YearFirst " _
                + "FROM tblDetails INNER JOIN Academic ON " _
                + "tblDetails.ID = Academic.AcademicID " _
                + "WHERE tblDetails.ID = '" & Trim(Me.txtSearch.Text) & "'"

    da = New OleDb.OleDbDataAdapter(sqlSearch, con)
    da.Fill(ds, "HumanResource")
    con.Close()

After pulling the data, I want to update this data (I think its the same as adding new data) and I tried to use this code:

       Dim updateCommand As New OleDb.OleDbCommandBuilder(da)
        ds.Tables("HumanResource").Rows(inc).Item("FirstLevel") = cmbFirstLevel.Text
        ds.Tables("HumanResource").Rows(inc).Item("FirstAward") = txtFirstAward.Text
        ds.Tables("HumanResource").Rows(inc).Item("PlaceFirst") = txtPlaceFirst.Text
        ds.Tables("HumanResource").Rows(inc).Item("YearFirst") = txtYearFirst.Text

        da.Update(ds, "HumanResource")

But this method does not work, with the following error msg "Dynamic SQL generation is not supported against multiple base tables."
Microsoft further says that "..This often occurs when the database table does not have a primary key column, or the SELECT command uses JOINS."
So I think I need custom codes for INSERT/UPDATE to work here, since I use JOIN. I have googled for the codes to no avail. Can someone help me please? The codes for UPDATE/INSERT where JOIN is used.

Thanks in advance.

savedlema 17 Junior Poster

Hi buddy!
It was good that you did not remmove this post. I found my answer here! I was wondering on how to actually insert datetime to access from VB date time picker. If you meet one person today, tell him/her that "We learn through others' mistakes".
Stay well!

savedlema 17 Junior Poster

Hi friends!
Look, I'm managing a Windows 2003 Server machine. I have logged in as Administrator (as always), I have been able to install few software that I have wanted to install, but I have a problem installing this Vodafone Mobile Broadband, a modem that I will use to connect to the internet. It brings a message "This program requires administrative priviledges to run......." and it eventually exit. I tried right-click and "Run As" then selected Administrator and gave the password but no success. I have googled this but the post that came closer spoke about a Windows 7 machine.
Any help please? I have an Active Directory in this Server, and it is the Domain Controller. PS:I also wonder, can also log in to this computer locally and not to the domain?

Thank in advance folks.
Frank.