G_Waddell 131 Posting Whiz in Training

Hi,

You could try something like:

Private Sub EnableDisableMyControls (Optional ByVal bEnabled As Boolean =TRUE)
    NClose.Enabled = bEnabled
    CloseNote.Enabled = bEnabled
    CloseNoteContext.Enabled = bEnabled
    CloseNoteX.Enabled = bEnabled
End Sub

If tabC.TabCount =1 Then
    EnableDisableMyControls(TRUE)
Else
    EnableDisableMyControls(FALSE)
End if
G_Waddell 131 Posting Whiz in Training

What selection mode is your datagrid using? If it is rowselect I think you will have use SelectedRows instead of CurrentRow, CurrentRow gets the row of the current selected cell but if you are using the rowselect mode you have not selected a cell but a row and so you will always get a zero.

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

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

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

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

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

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

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

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

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

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,

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

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

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

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 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,

Can you post some of the code and we will see what is happening? Off the top of my head , you could try a SELECT DISTINCT query to get rid of repeating values - it depends on what your DB structure is if you should be getting them or not.

G_Waddell 131 Posting Whiz in Training

I think that JorgeM has found what was missing.....

G_Waddell 131 Posting Whiz in Training

Type this into google "Joining tables in a SQL query"

G_Waddell 131 Posting Whiz in Training

Hi,
I take it this is on an Intranet site. If not, you should look at using other methods of authentication for security reasons.

Anyway now that is out of the way, are you sure the user is acessing the site as their own account and not the IGuest user of the web server?

Check the Authentication method of the Site on the server. It depends on which version of IIS you are using where it is but, if anonymous access is enabled and other forms of authentication are disabled then the user will be logging into the site as the webservers iGuest user which is a user local to the web server and not a domain user.

Also, check that the Application pool being used by the site loads the user profile and doesn't run as a particular user (again depands on the version of IIS you are running how you do this.)

If this is happening during a debug / step through then I think by default it should authenticate you automatically (although, bear in mind the above when you do deploy to live site, ) in which case you need to to look at your authentication methods in the config file which I'm a bit rusty on, (I haven't built a web site from scratch since last December,) check the user is actually authenticating under their domain account may be by returning the account name in a message box or something.

G_Waddell 131 Posting Whiz in Training

Hi
I use the SubversionEdge Kit from Collab net it sets up the Server for you, running through apache. BUT They also over the CollabNet Desktop for Subversion and ANKH SVN. I think this is what you are actually looking for, the desktop will let you connect to your subversion server via the desktop then ANKH SVN is a plugin that goes direct into any version of Visual Studio and runs off the desktop to enable you to manage and check your files in and out of your respository as you would of via Source Safe except of course , it allows branching , concurrent development etc. http://www.collab.net I'm sure there other tools out there that let you do this but it's what we use.

G_Waddell 131 Posting Whiz in Training

Hi,

I'd use one of the many free scren scraper tools there are out there and save myself the bother.... you can get them to export to csv or xml and take the file into read....

G_Waddell 131 Posting Whiz in Training

thanks dude!
i attached the picture of my project..and that is how it looks like

Looks nice, glad I could help - don't forget to mark as solved....

Also, you may wnt to loop through the individual LinkLabel controls and reset their colours before setting the target one, incase the user has already selected one person then selects another.

G_Waddell 131 Posting Whiz in Training

Hi,

dim MyLabel as linklabel

MyLabel = form1.findcontrol(Textbox1.text)
If MyLabel isnot nothing then
  MyLabel.BackColor = Red
End if
G_Waddell 131 Posting Whiz in Training

hi

MyLinklabel.backcolor = red

Here is a link to all the system colours
http://msdn.microsoft.com/en-us/library/system.drawing.color.aspx

G_Waddell 131 Posting Whiz in Training

You can use JOIN keyword to link two or more tables and retrieve data from those tables based on similar columns that exist in those tables or you could make good use of subqueries

Err.... sorry isn't that what I more or less told them....

G_Waddell 131 Posting Whiz in Training

Hi,

Your query has no joins, look up INNER JOIN and OUTER JOIN in Google. Basically JOIN tells your query how to join the tables together - you can do it by the where clause as you have done but something in your query is causing an ambiguous join…

What database are you using? There is a database forum under Web development bizarrely enough, (Maybe this should be out on its own forum?) which has sub areas for the common Database servers.

Hopefully this will get you started on the right path...

G_Waddell 131 Posting Whiz in Training

Hi
One thing I noticed was you commented out the line where you defined dr as as SQLDataReader but I don't see:

dim dr as OleDbDataReader

So how does your code know what dr is supposed to be?

G_Waddell 131 Posting Whiz in Training

Hi,

Just taking a guess here but what does colProcesses.Count actually return?
How about:

If colProcesses.Count > 0 Then
   ToolStripStatusLabel1.Text = "FSX Status: Connected"
Else
      ToolStripStatusLabel1.Text = "FSX Status: Not Connected"
End if

OR

If colProcesses.Count IsNot Nothing then
 ToolStripStatusLabel1.Text = "FSX Status: Connected"
Else
      ToolStripStatusLabel1.Text = "FSX Status: Not Connected"
End if
G_Waddell 131 Posting Whiz in Training

Hi
You've defined your SQL insert statement but I don't see you doing anything with it.
For insertting records to a database I just do something like this as I find it easier: (actually I'd use a SQL Database with a stored procedure as it is more secure and SQL express is free)

sub SaveMyRecord ()
dim sql as string

sql = "INSERT INTO [Table1] (Tag_ID, fName, sName, Address, Contact, car_Make, car_Model, car_Reg) VALUES ( '" &Tag_IDTextBox.Text &"', '" &FNameTextBox.Text &"', '" &SNameTextBox.Text &"', '" &AddressTextBox.Text &"', '" &ContactTextBox.Text &"', '" &Car_MakeTextBox.Text &"', '" &Car_ModelTextBox.Text &"', '" &Car_RegTextBox.Text &"')"

dbProvider = "Provider = Microsoft.ACE.OLEDB.12.0;"        
dbSource = "Data Source = C:\myProjects\jmCarPark1\jmCarPark1\JMdataBase.accdb;Persist Security Info = True;"         
con.ConnectionString = dbProvider & dbSource         
con.Open()
dim cmd as OleDBCommand
with cmd
  .Connection = con
  .text = sql
end sub
cmd.ExecuteNonQuery()
G_Waddell 131 Posting Whiz in Training

The Intellisense should be putting a wavy line under where your syntax is wrong or may lead to issues

G_Waddell 131 Posting Whiz in Training

Try:

SELECT int_Exa, COUNT(*) as nbrTest FROM TEST GROUP BY int_Exa

The result set should will list each exam in the TEST table with a count of the number of each.

If you want a count of ALL exam (not just the ones that have tests,) then try:

SELECT EXAMIN.Int_Exa, ISNULL(T.nbrTest, 0) AS nbrTest FROM EXAMIN LEFT JOIN (
SELECT int_Exa, COUNT(*) as nbrTest FROM TEST GROUP BY int_Exa) AS T ON EXAMIN.Int_Exa = T.Int_Exa ORDER BY EXAMIN.Int_Exa

This will take each Int_Exa in the Examin table and left Join it to the Resultset from the previous example. If there is no match (i.e. no record in the TEST table,) it would return Null but the ISNULL function allows us to substitute the value 0.

G_Waddell 131 Posting Whiz in Training

Hi Guys,

Look up any of the following in Google or similar:

ADO.NET DataReader
ADO.NET DataAdapter
ADO.NET Command

Pay attention to the examples given...

Also use the Access QBE to design your SELECT Query and switch to SQL view to get the Query in Access compatible SQL.

With out more specifics i.e. code that's the best help I can give you.

G_Waddell 131 Posting Whiz in Training

Hi
The SQL is basically the same...

Provide more details on where exactly you are stuck and we'll see what we can do..

G_Waddell 131 Posting Whiz in Training

Hi

You should do something like this:

sub EmployeeSearch 

dim  EmployNo as integer
dim mySQL as string

EmployNo = cint(MyTextbox.text)
mySQL =  "SELECT * FROM tblEmployee WHERE (EmployeeNo =" &EmployNo &")"
'run query on db and get result.
G_Waddell 131 Posting Whiz in Training

Hi
You would probably be better off using the FolderBrowserDialog class (see http://msdn.microsoft.com/en-us/library/system.windows.forms.folderbrowserdialog.aspx) You can use this to get the folder path then loop through the files and sub directories in the root folder.

G_Waddell 131 Posting Whiz in Training

Okay Sir i get u so can you plz show me the whole program what at the end will display,i mean starting from the inputs,proccessing and outputs,and plz do this kind of loops For...Next,while and do untill bcoz im familiar to them.I hope you still remember my program statement.Still vesh2009

Hi,

So you want me to do your assignment / project for you???

You can pay me at Euro 25 /hour or try it yourself. If you get stuck come back and post a new post with your code on the part you are stuck on.

The only place success comes before work is in a dictionary

G_Waddell 131 Posting Whiz in Training

hi there!calling for help
I have this program/project that is more on loops that says,write a program that will display a Fibonacci series when you click on a button.The first number entered should be indicator how many numbers of the series should be displayed a generated.So im confused whether using For...Next or While loop.
help!

Hi
You really should post this under your own thread.
As for your question you can use For... next, While...End While, Do While...Loop and Do Until...Loop they are all valid for looping. Basically use whatever you are more comfortable with.:)

dim i  as integer

for i=0 to Mylimit 
'do something
next

While i < limit
'do something
  i=i+1
End While

Do While i< limit
 'do something
 i=i+1
Loop

Do Until i = Limit
 'do something
 i=i+1
Loop
G_Waddell 131 Posting Whiz in Training

Hi,
You do not define the function or method with in your sub routine, it is available to all subroutines and functions with your form. Take line 10 out and it should work.

Dim CalculateCharges As Decimal 'not needed as CalculateCharges is a function

You have specified that the function takes in a double and returns a decimal when you defined it:

CalculateCharges(ByVal hours As Double) As Decimal

I can't see where your code (or posting,) mentions reading from a text file though.

G_Waddell 131 Posting Whiz in Training

Hi,

I'd be very cautious about letting anyone upload an exe file to my site. There is a reason the FTP server is blocking them...

That being said there's times you need to allow it too. I usually have a list of blocked extensions that I check before upload and if it is one of them, I ask the user to zip the file first. You don't want to just turn the file to a .exe without checking it out first.

dim BannedList as String =".exe,.vbs,.js"
...

if instr(BannedList, Myextension) <> 0 then
''show message
else
 'allow it
end if