G_Waddell 131 Posting Whiz in Training

Hi guys,
I hope we didn't scare Rahul47 away!

G_Waddell 131 Posting Whiz in Training

@IsaacMessi10
What happened did you get an error? What did it say? Show us your code...

G_Waddell 131 Posting Whiz in Training

Hi,

Row 11 could be different in some way did you manually populate the table? Is there a chance there is a leading or trailing space for example ("United" vs "United ")? Are the team names in the same case ("United" vs "united")

If you remove the clause about the count of the items and just populate the text box does it appear?

G_Waddell 131 Posting Whiz in Training

Hi,

First of all I would not use firstname to identify the record. Say you have 3 people in your database John Brown, John Green and John Smith and you want to update the John Green record you will end up with 3 identical John Green records. Give your employee table a primary key e.g. EmployeeID and place this as a column in the datagridview. (If you don't want the users to see it, you can set its visible value to false i.e. mygrid.columns(0).visible=false)
Now you can use this in your where clause and only the employee you want is updated.

Also you should probably add the items in the where clause as parameters too for consistancy.

What database are you using? If it is SQL Server you should run a SQL profile to see exactly what is being run on the database when you update the grid.

G_Waddell 131 Posting Whiz in Training

Hi,

I'm a bit rusty with this but I don't think you can just copy over the value from one table to another. I think you will have to stream the image out of one table and then put that stream of binary data back in the other table.

I assume you have code to upload the image to the database and read the image in from the database... In this case, you will be combining them both in reverse i.e. read the image from the database and upload it to the other table.

G_Waddell 131 Posting Whiz in Training

Hi Guys,
The way I look at my apps from a security perspective is the more layers of security the harder it is to crack. So generally what I do is the following (Not saying this is what you must do, just what I do)

Layer 1 form input, block any characters except A to Z, a to z and 0 to 9 also only allow space delete and backspace etc. ( of course you can let in other characters if that suits)

Layer 2 Code that processes the input filters out unwanted character from input as well (This is in case they some how get past layer 1)

Layer 3 Data Access Layer; I place all data interactions with in a Class with set functions to retrieve data and only call stored procedures - this means I can reuse common data functions/ opearations and I don't create queries on the fly which leads me on to layer 4.

Layer 4 backend database; As I said, I avoid creating queries on the fly and use stored procedures I use a dedicated DB user for my app whos rights are limited to Execute permission on the stored procedures I need. That way even if an injection attack got through they would not have the right to drop or modify tables or database.

G_Waddell 131 Posting Whiz in Training

True, you could allow ' if you wanted to but I suspect that as you are designing the log in form etc. you are probably in charge of what constitutes a username i.e. you could insist on ONeal or have them not be actual names e.g. JN234

The other reason I was thinking of limiting the input like this is to block the user entering any extended SQL character that they could use deliberately or inadvertantly to cause problems. ' was given as an example but ; for example can also be used to cause merry hell on a SQL query.

G_Waddell 131 Posting Whiz in Training

As the guys said above, there are ways and means to get around using the word application... It just means you will not be using the Interop application.

G_Waddell 131 Posting Whiz in Training

Hi
I would suggest using the keypress event of the login name to only allow letters (Upper and Lower case,) and the numbers 0-9 and some function keys (e.g. backspace, delete and space) that way they will only be able to input valid characters into the login box and correct any error they made.. If it is a webpage login you could do something similar with client side Javascript or use Ajax...

G_Waddell 131 Posting Whiz in Training

Hi
Do you still get "&Open Exam" as the result? This looks to me like it is coming from the parent "Open Menu Item" rather than the item you are clicking. You may have to add the handler after you add the Item to the menu.

G_Waddell 131 Posting Whiz in Training

hmmm do you wish to update the rows at the press of a button etc? or just have it done on edit?

The approach you are using indicates you wish a user to press a button to update...

You could try something like this:

sub UpdateStatus()
dim DGVRow as datagridviewRow
dim Query As string = "UPDATE Status WHERE Repairnumber = @repairnumber"
Dim Conn as new sqlconnection(my.Settings.Smitty)
dim Cmd as sqlCommand
dim iUpdated as integer
for each DGVRow in repairinventorydatagridview.selectedRows
    if conn.state <> ConnectionState.Open then
        conn.open
    end if
    cmd= new sqlcommand
    cmd.Commandtype = CommandTypeText
    cmd.text = Query
    cmd.Connection = conn
    'Is this right? Your code give a different parameter name but the string is looking for @repairnumber
    cmd.paramaeters.addWithValue("@repairnumber", ordernumber) 
    if cmd.ExecuteNonQuery > 0 then
        'count the rows your updating 
        iUpdated +=1
    end if
next    

msgbox (iUpdated &" Rows updated.")

If not, you should look at specifying the Update command for the SQLDataAdapter you use to populate your Datagridview with.

G_Waddell 131 Posting Whiz in Training

Try moving the line con.open() to above cmd = new oledbcommand(sql, con) i.e. have your connection open first
To check that the connection is open before executing the command, you may want to try this:

If Con.State  = ConnectionState.Open Then
    dim dr as OleDBDataReader = cmd.ExecuteReader
    ....
End if
G_Waddell 131 Posting Whiz in Training

Hi

The answer to the question you asked is yes of course, the world is littered with client server applications using a common database. (Including this very web site.)

The answer to your question I suspect you are actually asking depends on the database server / program you are using.

The database should be able to support concurrent access/users.

For instance, Microsoft Access is a database but Microsoft themselves do not recommend it for concurrent access (although I have observed client server systems using it but they became unstable after heavy use). SQL server is a database server that Microsoft does recommend for concurrent access (Including SQL Server Express Edition which is free).

If you don't fancy Microsoft then MySQL is also free and very popular and supports concurrent access.

G_Waddell 131 Posting Whiz in Training

Hi

RepairInventoryDataGridView.Rows(4)

Will give you a collection of cells on row 4 of the datagrid. Your Update statement is looking for a single parameter in this case the Repairnumber.

Even if your grid only consists of a single column, I still think you will have to quantify exactly what you are looking for e.g. RepairInventoryDataGridView.Rows(4).Cells(0).value

It would probably help to put in place some code to check it is a valid value i.e. not empty or null before putting it into your SQL Parameter.

G_Waddell 131 Posting Whiz in Training

Hi,

WebBrowser.WebBrowser1.Navigate(BookmarksList.SelectedItems)

SelectedItems implies a collection to me - did intellisense highlight it?

I'd say your looking for either

WebBrowser.WebBrowser1.Navigate(BookmarksList.SelectedItem)

Or

WebBrowser.WebBrowser1.Navigate(BookmarksList.SelectedItems(0))

However, given the error message when you tried SelectedItem.Text is telling you text is not a valid member on type string I'd say the first option is the one you want i.e. SelectedItem

G_Waddell 131 Posting Whiz in Training

Ahhh I did wonder...

As tinstaafl says as you dynamically build the list use the AddHandler to point the click event to a common subroutine based on the normal click event.

You can then use the sender parameter to identify which item fired the event.

G_Waddell 131 Posting Whiz in Training

Hi
I take it this is the standard Menu strip class? In which case, you are not actually selecting an item, you are clicking on it.

So what you would do is use the on click event of each item to populate the messagebox or carry out the other actions.

sub item1_Click (byval sender as object, byval e as system.eventargs) Handles item1.click
msgbox(item1.text)
end sub
G_Waddell 131 Posting Whiz in Training

Hi
Are you sure the default format is yyyy-dd-MM HH:mm:ss? Try formating it as yyyy-MM-dd HH:mm:ss (Serial date)

Dim eventdate As String = Format(DateTimePicker1.Value, "yyyy-MM-dd HH:mm:ss")

Also you may want to double check that syntax, - I'm always mixing my months and minutes up hence I usually do this:

Dim eventdate As String 

eventdate = Year(DateTimePicker1.Value) & "-" & Format(Month(DateTimePicker1.Value),"0#") &"-" & Format(DatePart(DateInterval.Day, DateTimePicker1.Value ),"0#") & _
            " " &TimeValue(DateTimePicker1.Value)

I know it should be the same thing but just in case....

G_Waddell 131 Posting Whiz in Training

Hi,

As adam_k said if you are using the word libraries and interop to access word, the users machine must have a copy of Word installed.

Furthermore, if you specifically include references to a Word library you are depending on the user having the same version of Word installed i.e. Word 2003 uses a different library than Word 2010

To get round the library issue it is better to use late binding to access word:

'Example using an included reference to Word library - depends on client having same version

Imports Microsoft.Interop.Word 

dim MyWord as Word.Application
dim MyDoc as Word.Document

MyWord = new Word.Application
MyDoc  = new Word.Document 'I don't think you actually need this line
MyDoc =  MyWord.Documents.Open (FilePath)

'Example using late binding  - uses whatever version found on client
dim MyWord as Object
dim MyDoc as Object

MyWord = createobject("Word.Application") 
'create object will go and find whatever program string matches
MyDoc = MyWord.Documents.Open(FilePath)
G_Waddell 131 Posting Whiz in Training

Hi,

You should look at the Keypress event for the textbox

G_Waddell 131 Posting Whiz in Training

Find something that interests you, and see if you can come up with a program to make some sort of associated process easier. Alternatively if there is an aspect of your course that interests you that you can create a program around use this.

If you are really stuck ask yourself:

  1. Are you really pursuing the correct area of study? If you have a career as a programmer you will be expected to take / flesh out vague user ideas and turn them into programs
  2. Should you maybe get a hobby or interest? Or get out a bit more and get ideas to use?
Begginnerdev commented: A more graceful way to word it. +0
G_Waddell 131 Posting Whiz in Training

Do you have to use Notepad /text files as your storage medium? It seams to me it would be a lot quicker and more efficient to use a database to store the recipes and then out put this data to text file - you would be able to do the calculation of quantities as you output to the file too.

Off the top of my head, you could have a recipe table containing the instructions and quantity produced. Then maybe an ingredients table linked back to the recipe where you could specify item name, quantity and unit of measurement. Then if your base recipe is to say produce a 200 gram cup cake and the user wants to make a 600 gram cake you can multiply each items quantity value by 3 to get three times as much.

Begginnerdev commented: Great idea! +6
G_Waddell 131 Posting Whiz in Training

Hi,

I'm not sure what it is your are trying to do, are you displaying answers to questions?

G_Waddell 131 Posting Whiz in Training

Check and see if your datatable is still populated after your update...

G_Waddell 131 Posting Whiz in Training

"Why the only place sucess comes before work is in a dictionary - a journey of self exploration"

G_Waddell 131 Posting Whiz in Training

Hi

I think your values would have to be in the order 1,2,4,8,16,32,64,128,256 etc

i.e. if I used a value 3 then SelectedOptions AND 2 = 2 would be true as 3 = 11 and 2 = 10

G_Waddell 131 Posting Whiz in Training

How about "Why you should not go onto forums and expect other people to get your work done for you"?

OR

"01010101010101011010101 Isn't Binary Fun?"

OR

"<Insert Tutors Name here> <Insert Insult here>"

I'd be willing to bet no one is using any of them

G_Waddell 131 Posting Whiz in Training

Hmmm....

There are are a couple of ways you can do this, seeing as you only have one field to store it in and you could loop through your items as you are doing and if the item.checked then append it to a string that you then store in the DB field. This is nasty though when it comes to reading back.. as you will have to parse through a long list of delimited text to see what the user clicked.

If you understand bitwise logic you could store the whole thing as a single numeric field and use comparisons to see which checkboxes were checked. I've done this before for storing a users options on a web site but it was ages ago and I can't quite remember how I did it.

I think I assigned a numeric ID to each option then when the user selected it I used an OR to store it in my database field i.e. NewUserValue = OldUserValue OR SelectedOptionID

Then when it came to to see if the user had checked the option, I used an AND like so
IF UsersSelectedOption AND UsersOption = UsersOption then - option is selected

G_Waddell 131 Posting Whiz in Training

Hi,

I can't tell until I see your code...

Is it you want to store which checkboxes the person has checked them?

G_Waddell 131 Posting Whiz in Training

Hi,

Sorry I'll confess I didn't go through all that code BUT I find the best way to handle dates is to put them into DD MMM YYYY format i.e. 23 Nov 2012 Or YYYY-MM-DD 2012-11-23. To get your value back from SQL in DD MMM YYYY format instead of
CONVERT(varchar, dt, 105) AS TheDate
try CONVERT(varchar, dt, 106) AS TheDate

I can't off the top of my head remember the code value for the other one (Serial date format,) but I'm fairly sure Crystal will be able to understand either... It's actually how SQL store dates natively

Kingcoder210 commented: Thank you very much! It works! But it shows date like 01-Jan-2012 there in combo box. But my client wants to see date like 01-01-2012. Would you please tell me what should I do? +1
G_Waddell 131 Posting Whiz in Training

Hi
I'm not 100% sure what your asking, my first guess is that you want to put the results of a query that queries two tables into your gridview? i.e. Get advTitle from another table into your grid?

You need to join the two tables in your select query then use a dataadaptor to fill a dataset with the query result. You will then be able to retieve the Result set as a single datatable:

'I'll assume your using a SQL database
dim DA as sqldataadapter
dim DS as new dataset
dim DT as Datatable
dim cmd as sqlcommand
dim conn as new sqlconnection ("Your connection String")
dim sSQL as string
dim advidid as integer  'You'll populate this with the correctID 

'Now formulate your SQL query I don't see what your first table was called - I'll use tblJobApp
sSQL = "SELECT tblJobApp.userID, tblJobApp.advid, tblJobAdv.Title, tblJobApp.Remarks" & _ 
"FROM tblJobApp INNER JOIN tblJobAdv ON (tblJobApp.advidid = tblJobAdv.advidid) " & _ 
"WHERE (tblJobAdv.advidid =" &avidid &")"

If conn.state <> connectionstate.Open then
    conn.open
end if

cmd = new sqlcommand
cmd.CommandType = Commandtype.text
cmd.CommandText = sSQL
cmd.Connection = conn

DA = New SqlDataAdapter
DA.SelectCommand = cmd
DA.Fill(DS)
DT = DS.Tables(0)

MyGrid.Datasource = DT
MyGrid.Columns(1).Visible = false 'will hide the avidid form the users
G_Waddell 131 Posting Whiz in Training

Hi
I'm not 100% sure Access would support this but your query syntax is wrong anyway.
I assume field QTY is a numeric type i.e. not a string.

In your query you have encapsulated the qqttyy value in Single quotes i.e. your query says it is a string:

UPDATE Inventry SET QTY = QTY - ' " &qqtty &" ' WHERE CODE ='" &codee &"'"

i.e. say qqtty is 6 if the above was typed directly into access this is what you get:
UPDATE Inventry SET QTY = QTY -'6' WHERE Code='MyCode'

In otherwords, if QTY is a number you are trying to take the String value "6" from it.

Try dropping those single quotes so you will have:
UPDATE Inventry SET QTY = QTY - 6 WHERE Code='MyCode'

Not 100% sure it will work but at least you'll be subtracting numbers from numbers.

G_Waddell 131 Posting Whiz in Training

Hi
I'd say no, a browser only uses the class for CSS formating it can not identify a certain entity by anything other than it's ID field in Javascript and Name when the form is submitted

G_Waddell 131 Posting Whiz in Training

OK, you will need to use the UCase, and mid functions simply like this:

Function GetFormattedName AS String
dim FormattedName as string =""
dim FirstName as String =""
dim LastName as String =""

if trim(Textbox1.text) <> "" then
    Firstname  = trim(Textbox1.text)
end if
if trim(Textbox2.text) <> "" then
    Lastname  = trim(Textbox2.text)
end if

If Firstname <>"" then
    'Fully formatted Name   Uppercase First char    Lowercase the rest and add a space
    FormattedName = UCASE(mid(FirstName,1,1)) & lcase(mid(FirstName,2)) &" "
end if

If LastName <> "" then
    'Append last name in the correct format as above
    FormattedName = FormattedName  & UCASE(mid(LastName,1,1)) &lcase(mid(LastName,2))
End If

GetFormattedName = trim(FormattedName) 
'If we did not get any values we will get an empty string
'If we only got FirstName, the trim will strip out the trailing space.
End Function
G_Waddell 131 Posting Whiz in Training

Forgive my suspicious nature but that does sound awfully like you want to get up to no good…

G_Waddell 131 Posting Whiz in Training

Hi,

Do you mean manipulate Excel without it being installed on the machine or do you just want a way to do it in .net as opposed to vba?

If you don't mind excel being installed on the machine, then you can use Interop. Here is a sample: DevX.com

As for the other, I'm not 100% sure, I did do a project where I was trying to manipulate newer versions of excel as they are basically compressed XML files but I didn't get very far before we had to pull the plug.

G_Waddell 131 Posting Whiz in Training

Pgmer, he has already populated the MyTable table above, he needs to set the mydata4 table to be a copy of the Mytable table.
Dim Mydata4 as DataTable = MyTable.Copy This will copy the data structure and data from the MyTable to Mydata4.

Why though do you create and populate a table then create another table and then copy it? Why not just use the first table?

Anyway, it is possible that your query isn't actually pulling anything back before going into the While dr.Read loop, you should check if dr.HasRows
If not then throw up a message box telling you there is no data then you know if it is returning data or not.

G_Waddell 131 Posting Whiz in Training

Yes this is because you are posting from one page into another page. Therefore, the page has not posted back on to itself.

G_Waddell 131 Posting Whiz in Training

At a guess off the top of my head you would have to find the Latitude and Longitude of each place and use this information to convert into a distance between the two in KM.

The trouble is, even if you could figure out how to do this, you'd probably be giving the distances "as the crow flys" i.e. a straight line between the points.

If it is driving distances you want then you can't do that as a road will most likely not go in a straight line between the two points. Thats why Google show you the road their taking and allow you to move to alternative routes.

G_Waddell 131 Posting Whiz in Training

Got it!!

Should have either used
ReportViewer1.LocalReport.ReportPath = "Report2.rdlc"
OR
ReportViewer1.LocalReport.ReportEmbeddedSource ="MyApp.Report2.rdlc"
Not both!!!
Note: ReportEmbeddedSource uses the format ApplicationName.Report

G_Waddell 131 Posting Whiz in Training

Hi,

It looks like you are picking up some sort of formatting code or something. Have you tried opening the file in notepad? Are the characters appearing in the file in Notepad? I've had trouble in the past like this with csv files generated by excel especially if some sort of data sort was applied on it.

G_Waddell 131 Posting Whiz in Training

Hi,

I'm updating an application to .net from VB 6.0. It uses crystal reports to display reports but we get issues around versioning and having to have the client install Crystal so we would prefer not to depend on Crystal.

I was originally going to use an XMLReader object to read in XML generated by a SQL query and a XSLT stylesheet to transform into the reports and I had this working BUT:

  1. Currently I'm the only one who knows how to generate the XML through a SQL query
  2. I'm also the only one who really knows how to build a XSLT stylesheet
  3. It is not exactly easy to produce lovely reports ala Crystal using this method - No WSYWIG
  4. I don't want to be the only one producing these reports.
  5. We need some flexability around creating reports

It was suggested to me therefore to look into using the Visual Studio Report Viewer. I can't really find much on this apart from examples that use the built in wizards etc. But with the application we are discussing, we want it so that people here can design the reports with the reportViewer in VS but that when the application runs we can change the datasource to point to the applications connection and tables. i.e. I want to be able to load the data I want into the reports on the fly instead of using hardcoded data sources.

Here is what I have so far but although I get no …

G_Waddell 131 Posting Whiz in Training

Hi,

Unless you have a reason to open it in a richtextbox you can open it directly like so:

Module Module1
    Sub Main()
    ' Open the file 'example.docx' at the current program's directory.
    ' It will appear in a new instance of word.
    Process.Start("example.docx")
    End Sub
End Module
G_Waddell 131 Posting Whiz in Training

You will need to add a column of type datagridviewImageColumn to the datagridview how are you populating the view by setting the datasource? Or adding new rows programatically?

You will probably need to stream the image data into the column if you are getting the data from a database. There is an example on the Microsoft Website of working with a DataGridViewImageColumn

G_Waddell 131 Posting Whiz in Training

Hi,
Is this to go on a web page? or a Windows form?

On a webpage - you will have to have the webform reload itself on a timer via client side script as you can not force a users browser to reload and webpages are "static" until they reload / refresh. You will need to have captured that the other user has filled in the countermeasure in a place that the webform can check e.g. a database table

On a Windows form it will be much easier assuming that we are talking about two forms running on the same machine in the same instance of the Application. If not, you face the same problem of how does one form running under a certain instance on a certain machine know what a user on another instance or machine is doing?

G_Waddell 131 Posting Whiz in Training

Never used timespans before but at a guess I'd say:

Dim BreakTime As TimeSpan  = TimeSpan.FromHours(1)
Dim minless As TimeSpan = TimeOutHours.Subtract(TimeInHours)
Dim LessLunch As TimeSpan = minless.Subtract(BreakTime)
G_Waddell 131 Posting Whiz in Training

Change
Dim minless As TimeSpan = TimeOutHours.Subtract(TimeInHours)
to
Dim minless As Integer = CINT(TimeOutHours.Subtract(TimeInHours))

G_Waddell 131 Posting Whiz in Training

Hi All,
In my opinion, this is the best way to read in text from a csv file.

Take for example if you are importing addresses:

"1 Main Street","SmallTown","SmallCounty"

The above is fine and easy to parse in BUT what if an address like this was entered:

"App 1A, Tall Towers","SmallTown","SmallCounty"

By setting the parser setting delimiter to the comma AND also marking that the fields are enclosed in quotes, the parser knows the comma in the middle of the quotes is not a delimiter and therefore brings the text in as one field.

G_Waddell 131 Posting Whiz in Training

Hi I normally write my own command to do Updates Inserts etc then reload the data. But, I think you need to have the cb.GetUpdateCommand() line before the da.update

G_Waddell 131 Posting Whiz in Training

?? To do what???