G_Waddell 131 Posting Whiz in Training

As Pgmer Says you can carry out joins in your SQL query which would probably be the quickest and least memory intensive option.
OR

if in this instance you can not, you can go through one table and use the Select method on the other table i.e. DataTable.Select("My search criteria") this will give a collection of datarows in the table that match the criteria
for example:

Dim DT1, DT2 as datatable
Dim CustID as Integer
dim CustOrders() As DataRow
DT1 = ds.Tables("Customer")
DT2 = ds.Tables("Orders")

For Each DR as Datarow in DT1.Rows
    CustID = DR("CustomerID")
    CustOrders = DT2.SELECT("CustomerID = " &CustID )
    For Each Order AS datarow in CustOrders  
     'Do whatever
    Next
Next

OR

Use a dataRelation object to Join the tables in the dataset then get the child rows of the parent table:

Dim parentColumn As DataColumn = _
        DS.Tables("Customers").Columns("CustID")
    Dim childColumn As DataColumn = DS.Tables( _
        "Orders").Columns("CustID")

    ' Create DataRelation.
    Dim relCustOrder As DataRelation
    relCustOrder = New DataRelation( _
        "CustomersOrders", parentColumn, childColumn)

    ' Add the relation to the DataSet.
    DS.Relations.Add(relCustOrder)
Dim Orders() as DataRow
dim OrderNo as Integer
For Each Customer As Datarow in DS.Tables("Customers").Rows
    Orders = Customer.GetChildRows(relCustOrder)    
    For i as integer = 0 to ubound(Orders)  
        OrderNo = Orders(i).Item("OrderNo")
    Next
Next
G_Waddell 131 Posting Whiz in Training

I think you want something like this:

dim i as integer 

For i = 1 to 20
   ToonInfo = ReadSpecifiedLine(label6.Text, i)
   if Instr(ToonInfo, ":") <> 0  then
    'do what ever
    exit for
   end if
next

Instr searches for an instance of a string within a string if it finds the search string inside the string being searched it will return an integer value of the position within the search string in the string being searched. If not it will return a zero.
e.g.

Dim Works as string ="apple"
Dim Fruits as string  = "apple,pear,peach"
dim NotWork as string = "melon"
dim i, y as integer
i = Instr(Fruits, Works) 'i will equal 1
y = intr(Fruits, Works) 'y will equal 0 as "melon" is not in the Fruit string
G_Waddell 131 Posting Whiz in Training

Hi
Once you have a dataset object you do not need to connect to anything. But you have to fill it first e.g.

Dim DS As New DataSet
Dim cmd As New SqlCommand
Dim DA As SqlDataAdapter
'Assume you have set up a Sql connection MyConnection and a SQL Query in a string, SQLString
with cmd
    .Connection = myConnection
    .CommandType = CommandType.Text
    .CommandText = SqlString
end With
 if MyConnection.State <> ConnectionState.Open then MyConnection.open
 DA = New SqlDataAdapter
 DA.SelectCommand = cmd
 DA.Fill(DS)

I take it you are coming from using technologies like VB where everything was done with "live" connections and record sets through ADO?

Dataset was designed to get around all this once you have it populated, you only need to connect again to update data. You could think of it as a database (It's not but it's a good analogy)

Your Dataset should contain one or more datatables so to use an example from ADO, say I have a Recordset (Datatable,) I wish to parse through. So in VB I'd populate a Recordset and do something like this:

While not RS.EOF
   'do something
   RS.movenext
Wend

In VB.net I can now do this:

Dim DT as Datatable
dim DR as DataRow
DT = DS.Tables(0)
If DT.Rows.Count > 0 then
    for each DR in DT.rows
        'do something.. Instead of RS("") we can use DR("")         
    Next            
End if

If I want to create a new datatable in my dataset, I just do this:

Dim …
G_Waddell 131 Posting Whiz in Training

Noticed the same thing with adverts, program is at one level then adverts come on at a higher level - Now I tend not to watch live tv (unless it's a big sports event,) so I can fast forward through the adverts.

DeanMSands3 commented: Ditto. +0
G_Waddell 131 Posting Whiz in Training

Your Code has defined dr as a SqlDataAdapter not a SqlDataReader...

G_Waddell 131 Posting Whiz in Training
  1. Open Google
  2. Type "SqlCommand Class Vb.Net"
  3. Click Google Search

This is basic VB.Net in particular ADO.Net

G_Waddell 131 Posting Whiz in Training

Hi,

The short hand in SQL for localhost is as follows "<local>" or "." However this is not exactly what you are asking... Looking at your example your colleagues are using SQLExpress edition and you are using something like Developer or Enterprise.

By default, the licenced versions use the "default" instance i.e. your database would be localhost. SQLExpress installs itself as a named instance of SQLExpress. You can install other licened versions and also Sql Express as there own instance as well e.g. localhost\MyServerInstance or Localhost\SQLExpress and they would be independent of each other.

Off the top of my head I'm not sure how in code you could gather the various instances of SQL on your machine (as they are independant of each other) Normally I put a config screen or an ini file to configure my SQL connection but it still depends on knowing what instances you have...

This link may help at connection time Click Here

G_Waddell 131 Posting Whiz in Training

Hi,

To be honest why? There are plenty of cheap or free tools out there to do this for you

G_Waddell 131 Posting Whiz in Training

Unless the 4 tables hold the same fields (or at least fields you could map to each other,) then I doubt you would be able to do it as a single query...

But if you are trying to get them all in to one csv then you must be able to?

You will have to use nested sub queries or Unions but you must ensure that each query returns the Same fields so you can produce the results as a whole.

G_Waddell 131 Posting Whiz in Training

Hi,
You have 3 arrays (row1, row2, result) I only see you giving one of these arrays any dimensions (result) and you are recreating and so wiping out your result array each time.

Also, I see you are using integers e, f, g, i, j, k etc. but I don't see where these values are set.... You may just not be putting it in the sample.

Anyway one thing at a time, in order to use an array you must give it dimensions to store the data in for example say I had an array made up of fruit and the quantity of each I could do this:

dim FruitStock(3,1) as object

Fruitstock(0,0) = "Apple"
FruitStock(0,1) = 2
Fruitstock(1,0) = "Pear"
FruitStock(1,1) = 3
FruitStock(2,0) = "Orange"
FruitStock(2,1) = 1
Fruitstock(3,0) = "Banana"
FruitStock(3,1) =2

As you can see in VB.net arrays are zero based and can have multiple dimensions

"OK" I hear you cry, "I don't know how much fruit I have"

This is where you use a dynamic array...

'You can not increase the number of dimensions dynamically in an array
'You may only increase the size of the outer most dimension dynamically
dim FruitStock(1,0)  

'say we get values in from a query:

While MyReader.Read
'Resize and KEEP our values
    Redim Preserve FruitStock(2, ubound(FruitStock,2)+1)
'ubound = upper boundary of array , 2 second dimension Preserve = keep values
 FruitStock(0,i) = MyReader("Fruit")
 FruitStock(1,i) = MyReader("Amount")
i=i+1
While End
G_Waddell 131 Posting Whiz in Training

Hi,

Yikes! Always a nightmare taking over someone elses code especially if not documented.

You'll need to check what rows have changed and then update them individually.

So basically you'll need to compare each value that is there now with the original values then if it is different run an update query.

You could get round having to update the whole table line by line by disabling editing in the Datagrid, changing the selection to full row select, and putting an edit button under the grid.

In other words the user selects a row, clicks the edit button, you retireve the current values for that row. They edit the values in an edit panel which has been populated with the current values and a save and cancel button. If they hit cancel you hide the panel. If they save you perform run a SQL update query for that particular record. Then refresh your grid...

Not perfect, but it will save you trying to rewrite everything

G_Waddell 131 Posting Whiz in Training

Hi,
Depends on what you wish to do...

You will probably need to use client side javascript as you can not force a browser to reload/refresh from server side...

Unless you are doing something like counting between responses...

G_Waddell 131 Posting Whiz in Training

You look like you are setting the partno and the serialno after you have generated your SQL Insert string.... That is why you could be getting zero values

Try the following:

partno = cint(cbSARpartUsed1.selectedvalue)
serialNo = cint(cbSARserialused1.selectedvalue)

cmdInsertSite = New sqlCommand(String.Format("Insert Into SiteStock(serialno,partno,technicianID, dispatcherId,ATMID,DateDispatched) Values({0},{1},'{2}','{3}','{4}','{5:yyyy-MM-dd}')", serialno, partno, cbSARtech.SelectedValue, Ctype(dtpSARdispatchdate.Text, Date)), AddConn)

cmdInsertSite.ExecuteNonQuery
G_Waddell 131 Posting Whiz in Training

Hi,
It maybe easier to do the following:

In your database student table, insert a primary key called id and a second column called studentID the first column should be an autoincrementing field. So that when a new student is created they will have a unique ID. The second column will be a text column, you will put your "generated ID" into here.

Have a second table (call it something like pupil_count,) that has a session, course, level and students column. The students column will contain the number of students taking the course and the rest will be foriegn keys linking to their respective tables.

Now when a new student picks the course your insert query will insert whatever the values you want for your student are and then you return the primary key (id). Next check in your second table against the session, course, level, values to get the students value. If you get nothing back assume no one has yet signed up. Take this number increment it by one (that is the new number you are tacking on the end of your new generated ID) and update the students column to the new number for this session, course, level combo.

Now put together your new StudentID and update the value on the student record where the ID is the one you got earlier.

G_Waddell 131 Posting Whiz in Training

Are you sure the combo boxes are returning integers? I can't remember if it is SQL Server or the Sql Native client, but it will try and convert something it doesn't recognise as an integer to one and I wouldn't rely on it.
Try something like this where you ensure they are integers first:

 dim partno as integer 
 dim serialno as integer


 if isnumeric(cbSARpartUsed1.SelectedValue) andalso isnumeric(cbSARserialUsed1.SelectedValue) then
     partno = cint(cbSARpartUsed1.SelectedValue)
     serialno = cint(cbSARpartUsed1.SelectedValue)   
     CmdinsertSite = New SqlCommand("insert into SiteStock(serialno,partno,technicianID,dispatcherID,ATMID,DateDispatched) values (@serialno,@partno,@technicianID,@dispatcherID,@ATMID,@DateDispatched)", AddConn)
     CmdinsertSite.Parameters.AddWithValue("@serialno", serialno)
     CmdinsertSite.Parameters.AddWithValue("@partno", partno)
     CmdinsertSite.Parameters.Add("@technicianID", SqlDbType.VarChar).Value = cbSARtech.SelectedValue
     CmdinsertSite.Parameters.Add("@dispatcherID", SqlDbType.VarChar).Value = cbSARdispatcher.SelectedValue
     CmdinsertSite.Parameters.Add("@ATMID", SqlDbType.VarChar).Value = cbSARatm.SelectedValue
     CmdinsertSite.Parameters.Add("@DateDispatched", SqlDbType.SmallDateTime).Value = dtpSARdispatchdate.Text
     CmdinsertSite.ExecuteNonQuery
Else
    msgbox("Invalid Values selected")
End if   
G_Waddell 131 Posting Whiz in Training

Do you get any error message?
It maybe worth looking at setting the parameter type as well when you add them.

G_Waddell 131 Posting Whiz in Training

Hmmm I think you are going to have to rebuild the Array each time or end up with a load of empty values at the end of the array...

G_Waddell 131 Posting Whiz in Training

Hi,
Do you have account_id set to be an identity? I don't see you creating an Image value either do you have it set to accept null values?

G_Waddell 131 Posting Whiz in Training

Hi,
What edition of SQL are you using?
For most versions of SQL Server, Datasource should generally be the Server Name, SQL Express is the exception where it will be Server Name\SQLExpress or if you have a named instance Server Name\Instance Name

Try this link: Click Here

For example my database is stored on the Server AppServer and is the default instance I would use Datasource =AppServer

G_Waddell 131 Posting Whiz in Training

Hi,

Ever had an application that you want to store user specific settings on? e.g. login name or Form background colours, User specifc DSN connections etc. So the next time they run the app the information is there for them?

This can be achieved in VB.net with just a few easy steps.
Set up your user level application setting.
Write values to it
Read those values back

1. Setting Up User Scoped Application
In the Solution Explorer Window, select your project and right click. Select the Properties option in the sub menu.
In the Properties Screen there should be a Settings tab, open it.
You should now see a grid with the following columns:
Name The Name you wish to give the settting
Type The Type of settng value e.g. String, Integer etc.
Scope User or Application, Pick USER as this is user specific and can be modified programatically while the application is running.
Value A default value for the setting

Application Scope is a system wide fixed value that writes to app.config which can be changed programmatically but this change can not be accessed until the project is reloaded. User Scope writes to a file in C:\Documents and Settings and can be accessed at any time by the program for the specific user.

2. Write Values to your Setting
As can be seen in the Example Sub StoreSettings once you have carried out step one above, you can read and write to …

G_Waddell 131 Posting Whiz in Training

BTW it's not a criticisim - just curious!

G_Waddell 131 Posting Whiz in Training

Hmmm... all valid points but the thing is with databases, theres the programming / querying aspect (web and Software Development) , the setting them up, and then things like tuning them up for efficiency.

I just wondered why it didn't have it's own category really.

G_Waddell 131 Posting Whiz in Training

God is dead - Nietzsche, Who's laughing now? - God

"The only place success comes before work is in the dictionary" - unknown

Stupidity is doing the exact same thing again and again in the hope it works and being suprised when it doesn't. - unknown

Fail to prepare, prepare to fail -Roy Keane Rep. of Ireland footballer Saipan 2002.

I'm afraid of the floor, it's not the height that kills you it's when you hit the floor. -Chadwell the Welsh philosopher Naked Video

"People such as scientist Stephen Hawking wouldn't have a chance in the UK, where the National Health Service would say the life of this brilliant man, because of his physical handicaps, is essentially worthless," US - newspaper "I wouldn't be here today if it were not for the NHS," - Stephen Hawking

"May you live in interesting times - and come to the attention of the authorities" old Chinese curse

G_Waddell 131 Posting Whiz in Training

I like my code slightly fried over a charcoal pit :-)

Seriously, I summarise at the begining of a function / routine, I comment gong through it, I indent and I use Polish or Prefix notation - Why? because I've lost days after being handed a project that someone else has started (or attempted) and I've been asked to fix / complete it trying to figure out what they where doing, why they did it and what was going on...

I always think that I could get hit by a bus and some other person will have to take over or that three years down the line I'll have to mod the code or build a newer version and I don't want to be spending half my time figuring out what it is doing.

If it is a more complex piece of code or a large project I also use a SDLC and document the whole thing with Tech specs , Functional Specs etc. Again due to past experience. Basically, if I'm coding for a client, and they come back to me and say it is not what was agreed I want to have documentation that they've signed off on to cover my butt maybe I'm just an old cynic

G_Waddell 131 Posting Whiz in Training

I think if they want it so if the user bookmarks a page lower down in the site or uses a url of a page that isn't the root that they will be redirected to the root page. i.e. http://www.daniweb.com instead of http://www.daniweb.com/development

G_Waddell 131 Posting Whiz in Training

No worries

G_Waddell 131 Posting Whiz in Training

Why are Databases listed under Web development? and not out on their own?

I've seen plenty of Database issue listed under Software development

G_Waddell 131 Posting Whiz in Training

Not too familiar with the model but it could be:
Laptop in hibernate mode - if you press keys etc what happens or power button again?
Some laptops use a catch or pin to detect if the screen is shut - could this be stuck?

G_Waddell 131 Posting Whiz in Training

As someone who has recruited in the past, my main concerns were:

  1. Did this candidate have the experience relevant to the position?
  2. Would this person fit in with my team?
  3. Would they enjoy working in this position?

I would also say that I have dealt with people from large companies who were a complete waste of time as well as some who were absolutely brilliant.

It is alot easier to "hide" in a large company where you are anonymous than it is to in a small company. People who try to "hide" in smaller companies don't usually last long.

Also in a smaller company you are more likely to have worked on a variety of different projects but that being said, you could argue jack of all trades master of none.

Experience and how you use it is the key.

G_Waddell 131 Posting Whiz in Training

Hi,

Ask the landlord would he take a bankers draft for the deposit - If I understand it correctly it will take time to clear the payment but unlike a cheque it is guarenteed by the bank. This means you have time to cancel if not contract is produced but he knows it will not bounce unlike a cheque as the bank would not issue unless they have funds best of both worlds for you both. Although I admit you may need to check with the bank if I'm correct.

I just know when paying for a car etc. I've always been advised to pay by bank draft.

G_Waddell 131 Posting Whiz in Training

The only place success comes before work is in the dictionary

G_Waddell 131 Posting Whiz in Training

1st of all the guy tried to help you and you just gave him abuse.
2nd You NEVER mentioned the web browser control on your original post.
3rd Your issue is with poorly formatted HTML.

If this is your attitude to someone helping you, then good luck getting anyone else to answer anymore of YOUR problems.

G_Waddell 131 Posting Whiz in Training

Hi Instead of passing in a fixed datasource to your radio list you will have to dynamically set the the datasource.

You will need to use the ItemDataBound event of datarepeater 2 to capture the question value that you can then use to populate your answers. (It may be easier to "grab" the value of the question if you store it's ID in a hidden field you you can then pass into your answers query)

There is an example like this based on customers and products here: Nested ASP.NET DataRepeater

G_Waddell 131 Posting Whiz in Training

Hi
This link will start you off in the right direction it will tell you all about the grid view control and getting the SELECTED ROW and navigating the CELLS to get the ID of the selected Record etc. that you could pass into the form to show the specific record details hint hint...
GridView Class

G_Waddell 131 Posting Whiz in Training

Hi,
If I understand you correctly, you wish that your users will always access your site through the root page?

In otherwords, if they have put a page further into your site into the browser URL you will direct back to the root page?

I would create a session variable on your root page probably with a value of True then on each of your other pages the first thing I would do is to check for the session variable and that the value is True if not, redirect to your root page.

G_Waddell 131 Posting Whiz in Training

This should start you off in the right direction:
MSDN

You should be able to update for whatever version of the .NET Framework you're using.

G_Waddell 131 Posting Whiz in Training

Believe it or not this site http://www.connectionstrings.com shows you how to connect to just about any datasource from ASP and ASP.NET etc.

G_Waddell 131 Posting Whiz in Training

By that I mean are you getting an error message? Where is the message? Or what is supposed to happen and what actually happens?

G_Waddell 131 Posting Whiz in Training

Ooops Forgot about the download part!!! You could put the file on a publically shared folder on your web server and point directly at it, BUT, I would not for security reasons. What you should do is stream a copy of the file down to them in their browser that way they are not actually accessing any folders on your servers. They will get a do you wish to save or view dialog box.

G_Waddell 131 Posting Whiz in Training

If you use a FileUpload server control you should be able to get this information and more, this is the link from the MS site:
Click Here

G_Waddell 131 Posting Whiz in Training

Hi
Few questions:
Is this Client side or Server side?
What language are you using?

G_Waddell 131 Posting Whiz in Training

Hi, I think it's great your posting your code but what exactly is wrong?

G_Waddell 131 Posting Whiz in Training
G_Waddell 131 Posting Whiz in Training
G_Waddell 131 Posting Whiz in Training

Depends what you mmean by "Right Side Bar" The scroll bar? or something on your page?

Anyway in ASP.Net if it is an object on your page you want to hide that is easy:

Object.Visible = false
G_Waddell 131 Posting Whiz in Training

Hi
What database are you using?

You refer to BooksDataSet and BooksDataSet1 what are they? Data sets? should they be the same?

How are you retrieving your data? DataAdapter?

G_Waddell 131 Posting Whiz in Training

Sorry,
I still don't see what the point of this is or what you are trying to do.

For example, say you have the following six users:

John Steven Smith
Billy Bob Jones
John Bill Smith
Fred Bob Roberts
Joe Tom Bloggs
Tom Bill Stevens

You want (assuming you list alphabetically):
Billy Bill Bloggs
Fred Bob Jones
Joe Steven Roberts
John Tom Smith
Tom NULL Stevens

G_Waddell 131 Posting Whiz in Training

One method would be to write a seperate sub routine that you call from your mouse click routine ands from where ever you wish to simulate the mouse click.

G_Waddell 131 Posting Whiz in Training

You need to loop through the RTF box line by line and pass the string (the line), through the Reverend Jims code

dim MyLines() as String
dim MyLine, userpass as string
dim i as integer = 0
MyLines = MyRTFControl.Lines

For i=0 to ubound(MyLines)
    MyLine = myLines(i)
    userpass = myLine.Split()(0)
    'do what you want to do with userpass
next
G_Waddell 131 Posting Whiz in Training

OK, Got this working:

Dim frmViewer As New frmProcessReportViewer 'New Form'
Dim StringWriter As New System.IO.StringWriter
Dim XsltArgumentList As New XsltArgumentList
Dim StylesheetPath As String ="MyStylesheet"
Dim doc As XPathDocument = New XPathDocument("CDCollection.Xml")

'Create an XMLCompiledTransform object and load the XSL stylesheet.' 
Dim Transform As XslCompiledTransform = New XslCompiledTransform(true)
Transform.Load(StylesheetPath)
Transform.Transform(doc, XsltArgumentList, StringWriter)
frmViewer.WebBrowser1.DocumentText = StringWriter.ToString
frmViewer.BringToFront()
frmViewer.Height = Me.Height
frmViewer.Width = Me.Width
frmViewer.ShowDialog()