G_Waddell 131 Posting Whiz in Training

Are you developing in ASP .net? Why not use a label or link label and handle the click event in your code postback?

G_Waddell 131 Posting Whiz in Training

Yes. Use visual studio. Under file you should see a create new project option, depending on which version you are using, (and if you installed the Visual basic option when you installed visual studio,) you should see a Visual Basic language option. Select /expand this and you will see a ASP.NET Web Application option in the new project dialog. Select this and you have started your project - all your code behind will be in VB.net

G_Waddell 131 Posting Whiz in Training

Your Select command does not bring back any primary key / identifer so the update does not know what record to update...

G_Waddell 131 Posting Whiz in Training

Can you show the code where ReportProgress event is fired?
Is your it being called by your classes?
Are your Classes in the form/module/Class that the sub is in?
You have declared the sub to be Private that means it can only be called by Routines in the same module/class/form as it. You will need to either use Public Sub or Friend Sub if they are not...

G_Waddell 131 Posting Whiz in Training

Basically, put a break point on the line where your SQL string is populated, go into debug mode - it will stop at the breakpoint, add a watch to the SQL string, copy the value for the SQL string out and paste on to the forum.

G_Waddell 131 Posting Whiz in Training

You need to specify the Delete command for your DataAdapter - you can do this inside your delete button or when you set it up.

Another option is to run a SQL command with a delete statement.

Your DataAdapter does not magically know how to delete data from the database.

G_Waddell 131 Posting Whiz in Training

connectionstrings.com

What string are you using? The default? I think though it may be a language/ locale issue as it is talking about the format of the string..

G_Waddell 131 Posting Whiz in Training

Depends if you are more comfortable with Databases or Interop.

Alternatively, you could output as .csv easily enough just using the System.IO and Streamwriter....

G_Waddell 131 Posting Whiz in Training

I copied and pasted the excel sheet content into a new blank excel workbook and this worked ok, I'd still love to know what caused it.

G_Waddell 131 Posting Whiz in Training

Hi,

I've written a routine for a customer to import sales orders into their Sage system. Everything was going well but the client has come back with a particular excel sheet that is not importing. He is getting a message to tell him the sheet is not in a valid format which comes from the results of a validation function I have in my routine. I have looked at the Excel workbook and there is only one sheet. The sheet only has two rows, one for the column headers (all there,) and a second containing a single order.

I debugged through my routine and the product column is coming back as "product_" even though there is no underscore character there hence it is failing the sheet as it can not find the "product" column.

My questions are:
1. What is causing the underscore character?
2. If I adapt my code to allow an underscore character at the end will I then have to call the column in my Select statement as "product_" instead of "product"?

I want to use OLEDB in order to sort the sales items in terms of customer so I can input a single order per customer per sheet rather than multiple orders for single items.

here is my code:

function ExcelIsValid() As boolean
Dim XLConn As System.Data.OleDb.OleDbConnection
Dim bCustomer, bProductcode, bProduct, bQty, bUnitPrice as boolean
Dim DT as datatable
Dim DR as datarow
Dim TableArray() as string
Dim i as integer

try
    ExcelIsValid …
G_Waddell 131 Posting Whiz in Training

See my post earlier, you should convert the values to doubles to ensure you are adding like with like.

G_Waddell 131 Posting Whiz in Training

Glad I could help

G_Waddell 131 Posting Whiz in Training

Hmmm...

First thing is I'd say this could be done a number of in different ways, really depends on what you are most comfortable with XML / XSLT or Parsing text etc.

Either way, I would make each of "Tags" unique to the piece of data you are applying.

The simplest routine I can think of is to have your Template text with the tags and then use a replace to input your data e.g.

function issueWarning (byref User as string, byref Template as string, byref Rule as String, byref InfractionPoint as integer, byref Topic as string , Optional byval DaySuspend as integer=0) as String
dim Output as string =""
Output = Replace(Replace(Replace(Replace(Template, "[USER]",User),"[RULE]", Rule),"[INFRACTION]",InfractionPoint),"[TOPIC]",Topic)
IF DaySuspended > 0 THEN
 Output = Replace(Output, "[DAYSUSPENDED]","You have also been issued with a " &DaySuspened &" Suspension."

Else
    Output = Replace(Output, "[DAYSUSPENDED]","")
END IF
Return Output
ENd function

As you can see, I'm just giving a simple example, you can make it as complex or as easy as you wish. Also, to save time I made it as a function that will return a completed string for use it your code and you pass in the template as a string - you could do this differently but I didn't want to type it all out :-)

G_Waddell 131 Posting Whiz in Training

Quick suggestion by default, if you place a date value with no time part midnight ie. 00:00:00 is assumed to be the time part. So if I'm doing a date compare like that, I add the time value "23:59:59" to my end date to ensure I catch any dates.

Also, different date formats can really cause problems e.g. is 02/05/2012 the second of May 2012 or the 5th of February 2012? - it depends what part of the world you are from.

I always format my dates (both from My code and from SQL) into a format that is unambiguous e.g. YYYY-MM-DD or DD-MMM-YYYY e.g.

dim sSQL as string
dim StartDate as String
dim EndDate as String


StartDate = format(InputDate1, "yyyy-mm-dd")
EndDate = format(InputDate2, "yyyy-mm-dd")  &" 23:59:59" 

sSQL ="SELECT CONVERT(nvarchar(30), MyDate, 106) AS MyDate From MyTable " & _
"WHERE (MyDate >= '" &StartDate & "') AND ( MyDate <='" &EndDate &"')"

Now your SQL server will know exactly what dates you mean and also it will return the date value in DD-MMM-YYYY format i.e. 02 May 2012, so your code will be able to understand it too.

G_Waddell 131 Posting Whiz in Training

Yes but instead of taking the time to analyse and understand the code you have just lashed it into your solution.

I gave you a rather large hint in my last two posts to what the issue is.

Let me Zero in further for you:

conn = "Datasource = & '" & m_server & "' &;Initial Catalog= '" & m_db & "';user id = sa;password = P@ssw0rd;" DataAccess.GetConnectionString(conn)

I will now spoon feed you what should be apparent if you bothered to analyse and understand the code before using it. Do you have a entry in your config app called Datasource="m_server";Initial Catalog="m_db";user id=sa; password=P@ssw0rd;? I think you'll find that you do not. Although you do have one called Myconname

People do not mind helping you but we are not here to program for you - It is through trial and error that we all have learned but only by understanding, analysing and following the code will you truely learn.. That's what debug mode is for.

G_Waddell 131 Posting Whiz in Training

DataAccess.GetConnectionString(conn)

G_Waddell 131 Posting Whiz in Training

Well On your config file you have a connection string called Myconname

Your function, GetConnectionString appears to take in the Name of the connection and look for it in your app config file..

Think about the code you are using - What is the String that you are passing in to that function?

I suspect you are modifying someone else's code with out understanding what it is you are doing...

G_Waddell 131 Posting Whiz in Training

Hi,

I haven't done this for a few years but I'm fairly sure there is a Worksheets.ActiveSheet method or .ActiveSheets(index) or something like it..

G_Waddell 131 Posting Whiz in Training

Hi,

I have no idea what level of expertise you have. But, looking at your message I'm going to guess you are just starting out. (If not, I apologise for stating the obvious).

You need to create a connectionstring and use ADO.Net to pull the data back from the database with a SQL Command or Datareader or DataAdapter

Are you familiar with SQL? - you will need to be to query the database for the data using SQL - lots of examples about (google will help).

To get the format of connection strings bookmark and use this site, Connectionstrings.com

Look up SQLDataReader, SQLDataAdapter and SQLCommand either here or on google for examples of retireiving data.

G_Waddell 131 Posting Whiz in Training

Connectionstrings.com should give you the connection string format.

You would use the name of the server on the domain (not necessarily same as website URL) - if you are getting a hosted solution then the host company should help you with these details.

E.g. say I host my site at www.fluffybunnies.com but my web server could actually be called something like MyWebBox1.. Or I could even have my database on a different server...

G_Waddell 131 Posting Whiz in Training

When doing the maths part convert the input text to type double:

Sub Addition()
dim Answer as Double

If IsNumeric(input1.text) AndAlso Isnumeric(input2.text) then
    Answer = cDbl(input1.text) + cDbl(input2.Text)
    Output.Text = Answer
Else
    Output.Text ="ERROR NON NUMERIC ENTRY"
END IF
End Sub

Or else when faced with "250" + "7.5" the code may convert the "250" to an Integer and the "7.5" to a double with the erratic results you are getting...

"Always add apples to apples and oranges to oranges or else you get fruit salad."

G_Waddell 131 Posting Whiz in Training

Isn't that what the good reverend sugguested about 9 hours before you?

G_Waddell 131 Posting Whiz in Training

If you cannot do it via datarelations (I suspect perhaps due to the M:M nature of the data in the tables,) try my Datatable.select example I gave earlier...

G_Waddell 131 Posting Whiz in Training

I think it is because you are usng a sqladapter and then checking for tables - you are getting a table back but does it actually contain data? Or is it empty?

I would use a SqlCommand object and run executescalar on it. Something like:

dim sSQL as string ="SELECT COUNT(UserID) FROM tblUsers WHERE (Userid = @id) AND (Password =@epass)"
dim cmd as new SQLCommand
dim UserCount as integer

with cmd
 .connection = MySqlConnectionObject
 .CommandType = Commandtype.Text
 .Text = sSQL
 .Parameters.AddWithValue("@id",txtUname.text)
 .Parameters.AddWithValue("@epass",txtPass.text)
 end with

 UserCount = cmd.ExecuteScalar

 If UserCount > 0 then
    'valid
else
    'invalid
End if

That way when you run executescalar on the command object you will get a zero back if it is not valid and a one back if it is - if you get a number larger than one your records have been duplicated...

G_Waddell 131 Posting Whiz in Training

You would probably have to search the file system for the file, which is not a good idea as it could take ages.

Why don't you include the report in your project and get it to install a copy with it that way you will know where it is.

If this is not an option, give the user a dialog box to navigate to it themselves. You could save the path in your application settings for next time so they would only have to do it once - if you can't find the file because someone moves it, then reprompt them for it.

G_Waddell 131 Posting Whiz in Training

I don't know why people still use Visual Studio 2008.

Lots of reasons:
For example, I work in a company the customises Sage Software, at the moment there is no need for us to upgrade to 2010 or 2012 as the Sage software is written on .NET 3.5 - When sage move up to a new .NET framework then we'll upgrade...

G_Waddell 131 Posting Whiz in Training

So you want to have 50 checkboxes, one for each U.S. state and track who has been in what state. All a checkbox will tell you is if or not it is checked. not who did or didn't check it.

Are you keeping a Dll file to hold who has been where?

I would have used a data grid to show the break down with columns like this:
State, Me, FamilyMember1, FamilyMember2, FamilyMember3

Under State you list the state, under your column and each familymember put a checkbox with it checked if they have been there.

You can store the data in a csv file and populate the whole thing from the file that way if you want to add another family member you just add a new column to the csv file.

So the CSV would look something like:

State, Me, Member1, Member2, Member3
Alabama,False,True,False,False
Alaska,False,False,False,False
Arizona,True,True, False, True
....
Wyoming,False,False,False,True

G_Waddell 131 Posting Whiz in Training

Interesting, it would suggest something is emptying the dataset somewhere..

Dataset.Tables.count would only give zero if there were no datatables in it.

I think you better post your code.

One thing you could try is to go into debug mode and put a condition breakpoint in on Dataset.tables.count ie. when this value changes break. If should then break as the data set is populated and where ever it empties...

G_Waddell 131 Posting Whiz in Training

Ahh... does the app come with a database? Perhaps it is storing the file there? If not I'd poke about the programfiles directory or see if the program has configuration settings that allow you to select where they are put... Does the supplier have a web site? Maybe it can help you.. I'm afraid you'll have to do a bit of detective work...

G_Waddell 131 Posting Whiz in Training

What part are you having a problem with reading the database? Or populating the listbox control? Post what code you have so far, where does it fall over?

G_Waddell 131 Posting Whiz in Training

dried banana chips - tasty

G_Waddell 131 Posting Whiz in Training

DRAT! I should have posted a profile picture :-)

G_Waddell 131 Posting Whiz in Training

I suggest asking the lecturer how he wishes you to supply it.

Anaother alternative is to make all links relative and create a deployment project and deploy to the CD. I take it you have a database? If it is Access include it in the project output and make your connection string a relative path to the access file.

G_Waddell 131 Posting Whiz in Training

You should be able to upload binary files to sqlserver - one of the binary field types such as image should let you.

Should also be examples on this dotted about the net - you may have to open the file the reader generates as a bit stream and then when reading back regenerate the file again to let your software read it.

G_Waddell 131 Posting Whiz in Training

Hi I take it txt16.Text actually contains text just I can't see it being populated.

Also you appear to want the results in a table, why not use a dialog form instead? You could remove its cancel button and use a datagrid to display the text you need - it would give you more control over how it all looked (and save you relying on unweldy strings)

G_Waddell 131 Posting Whiz in Training

I think Visual Studio 2010 uses .Net 4.0 by default, I've never used Studio express but on the full version, Under project the properties properties page there should be an area to tell you what version of the framework you are designing for. Also, in the full version you can create deployment projects for installing on other machines with necessary prerequisites - again not sure about Express

Since I've moved company, it's been a while since I was in Visual Studio 2010 - my new company customises Sage software which needs 3.5 so we're on Visual Studio 2008...

G_Waddell 131 Posting Whiz in Training

Yea exactly that, it works perfectly and i have a countdown of example: 10:58:23, then after a minute and a few seconds it would look like: 10:53:10, etc.. it works but like you said im stuck with the 24Hours.

You will probably have to store your "target date and time" as a variable and on the tick event check if the date now is equal to the target date. This will allow you to go beyond the 24 hour period.

G_Waddell 131 Posting Whiz in Training

Date formatting issues can be a real pain... if your database and computer have different date formats it can lead to all kinds of interesting stuff, dd/mm/yyyy vs mm/dd/yyyy even then you can still get different interpretations

I always try to format any date or date time value into a format where there can be no mistake to its value either and pass in as a string - The Database can then handle the format conversion, I also try to output in one of these formats from the database too:

  • dd-MMM-yyyy HH:mm:ss (e.g. "31-JUL-2012 16:29:31")
  • yyyy-MM-dd HH:mm:ss (e.g. "2012-07-31 16:29:31")
G_Waddell 131 Posting Whiz in Training

Does any other religion retain its membership by threatening to kill anyone who leaves?

Well the Christian Church did, Spanish Inquistion, Crusades, Burning of "Heratics" etc.

ANY reglion can and IS frequently subverted to suit the political ends of those in power or who wish to gain power.

G_Waddell 131 Posting Whiz in Training

You could specify and update command for your Dataset like this Updating Database with a DataAdapter OR something like this:

dim cmd as new OLEDBCommand

With cmd
.connection = myconnection
.CommandType = CommandType.Text
.Text = "MyUpdate Query"
end With
cmd.ExecuteNonQuery 
G_Waddell 131 Posting Whiz in Training

Hi you're on the right path but the syntax for INSERT is different instead of
ColumnName = Value you do it like this:

INSERT INTO TableName(Column1,Column2)
VALUES (@Column1, @Column2)
G_Waddell 131 Posting Whiz in Training

You'd need to know how exactly the php method encrypts the password. It's like asking someone to translate from English to Manderin Chinese unless you can speak both fluently and know the grammatical rules etc. then you've no chance.

I suspect that the exact method used by the PHP is not going to be widely available - if it were, I'd look at another way of encrypting your password.

I think you may have to find a third party tool that works with both or create your own identical encryption /decryption routines in both languages.

G_Waddell 131 Posting Whiz in Training

Hmmm... Never used these before but when you debug me.TimePlayer1 what do you get?

Is it the full date and time value or just a time value? I suspect it is passing just a time value and substituting the current date hence you are stuck in a 24 hour period.

G_Waddell 131 Posting Whiz in Training

Hi,

I've only ever connected to Relational Databases never flat files so I can't really help you there. However, once you have figured out how to put your data to a dataset, you would be hopefully able to something like this:

dim DS as Dataset
Dim DTCars, DTColors as Datatables

DS = new Dataset
'fill dataset
DTCars = DS.Tables(0)
DTColors = DS.Tables(1)
'need to hook into the actual columns as datacolumns
Dim parentColumn As DataColumn = DTColors.Columns("ColorID") 
Dim childColumn As DataColumn = DTCars.Columns("ColorID")
dim relColorCar As DataRelation = new DataRelation("ColorCars", parentColumn, childColumn)
DS.Relations.add(relColorCar)
'Get colours and which models are offered in this colour:
dim ColorRecord as DataRow
dim CarRecord() as DataRow
dim Output as String
For Each ColorRecord in DTColors.Rows
    Output = ColorRecord("ColorText") 
    CarRecord = ColorRecord.GetChildRows("CarColor")
    If CarRecord.Count > 0 then
     Output +=" is offered on these models:" &vbcrlf
     For each DR as datarow in CarRecord
        Output += DR("ModelID") &", "
     next    
    else
        Output += " is not available on any models"
    end if
Next

You may run into difficulty trying to do the joins as multiple cars will have multiple colour records... I'm not 100% sure it wont freek out over that.

G_Waddell 131 Posting Whiz in Training

I was going to say you could save yourself some time with a SiteMapPath control but I'm not 100% sure the SiteMap will differentiate between parameterised URLs, you could always give it a go though and see. Click Here for the microsoft page on the SiteMapPath control

G_Waddell 131 Posting Whiz in Training

How are you retrieving and storing your data? Dataset? If so are you remembering that the dataset is not connected to the Database once populated? i.e. you can insert/ modify/ Delete records in it's datatables (they're held in memory) but you have to make specific calls to update the Database with the dataset data.

G_Waddell 131 Posting Whiz in Training

I think it is your strings you are using for your queries

e.g.

SELECT value1,value2,value3 FROM Video WHERE ID = value

Then you try and add parameters

.Parameters.AddWithValue("@ID", value)

But your select statement is just a string i.e. the database has no idea what value is. You seamed to have mixed two methods up of passing data to your SQL query.

You either want to do something like this:

dim query as string = "SELECT * FROM Video WHERE ID =" &Value 'Value is added to string but not part of it.

Or This:

Dim Query As String = "SELECT * FROM Video Where ID = @ID"
'....
Cmd.Parameters.AddWithValue("@ID", Value)
G_Waddell 131 Posting Whiz in Training

I think under most circumstances the Datarelation is the way to go, especially if you are creating jions between multiple tables.

G_Waddell 131 Posting Whiz in Training

What object is it not able to create? e.g. Word? Excel? PDF? etc...

G_Waddell 131 Posting Whiz in Training

Try Posting the code you use when you resize and we can have a look.