Begginnerdev 256 Junior Poster

I actually ended up using a cookie that is stored upon log-on.

The problem persists with the site map. I can't figure out how to bind multiple sitemaps to multiple binding sources.

I have three sitemaps:

Basic User - A
Basic User - B
Administrator

Only the administrator sitemap binds, but that is due to it being the original sitemap.
The other two are modified versions of the original.

I am wanting to only render menu items that are relevant to the user.

Begginnerdev 256 Junior Poster

We are all human friend, and humans make mistakes.

No need to be emarrassed.

Begginnerdev 256 Junior Poster

Have you tried:

RichTextBox1.Text.Replace("ThisString","ThatString")
Begginnerdev 256 Junior Poster

You can make use of the PrintForm class from the Power Packs.

For example:

Public Class Form2

    Public WriteOnly Property _PrintForm As Boolean
        Set(value As Boolean)
            If value = True Then
                Dim pf As New PrintForm
                    pf.Form = Me
                    pf.PrintAction = PrintToPrinter
                    pf.Print()
            End If
        End Set
    End Property

End Class

Then to call it from form1:

Public Class Form1
    Private btnPrint_Click(ByVal sender As Object,ByVal e As EventArgs) Handles btnPrint.Click
        Form2._PrintForm = True
    End Sub
End Class

Or, you can manually print by using the PrintDocument event of a printing job.

This will require the use of the Graphics class.

TnTinMN commented: PrintForm to the rescue :) +8
Begginnerdev 256 Junior Poster

Using the WebBrowser would be the easiest solution. The problem being with it is that the scroll bars will be in sight.

You can set the document with something like this:

WebBrowser1.DocumentText = "<html> <body> <img src=""PathToMyGIF""Height='300' Width='300'> </body> </html>"
Begginnerdev 256 Junior Poster

Have you created a form with a tab control with a browser object inside the tab control, or have you created a custom control?

Begginnerdev 256 Junior Poster

Just noticed that your string:

Server.MapPath("~/Content/Reprots/Quote/EmployeeQuoteLandscape.rpt")

Has a problem: Reprots

Server.MapPath("~/Content/Reports/Quote/EmployeeQuoteLandscape.rpt")
Begginnerdev 256 Junior Poster

You will be working with the Graphics class.

You will need to define if you want the worms to be fixed variable, random, or mixed.

I am assuming you wanted mixed: certain width and colour

Here is an article that covers the basics on how to drawn in vb.net.

Begginnerdev 256 Junior Poster

If by old database path, you mean the path to your local database - you will have to change the a network path then re-deploy.

Begginnerdev 256 Junior Poster

Are you programming in WPF (XAML) or WinForms?

And when you say online/offline, what are you expecting to pull these values from?

A browser? Code? What exactly?

Begginnerdev 256 Junior Poster

You will have to elaborate on what an "Artistic Warm" is, friend.

Begginnerdev 256 Junior Poster

Is the pc on the same network? If so, just use the IP of the host machine.

"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=\\serverName\shareName\folder\myAccess2007file.accdb;"

Here is a wonderful reference for connection strings.

Begginnerdev 256 Junior Poster

Im sorry friend, you will have to create a new discussion and post your question there.

You can do so by following this link.

Begginnerdev 256 Junior Poster

That works well. The problem with this statement:

Dim str1 As String = "SELECT * FROM AdigratT WHERE [Bridge Name]='" & bridgename & "'"

Is leaving you open for SQL Injection attacks.

It is best to use parameterized queries:

  Dim str1 As String = "SELECT * FROM AdigratT WHERE [Bridge Name] = @Bridge"
  str1 = str1.Replace("@Bridge", "Test Bridge")

Try passing in the command:

If ComboBox1.SelectedItem = "Bridge Name" Then
    If TextBox1.Text <> "" Then
        Dim conn As New OleDBConnection("SELECT * FROM AdigratT WHERE [Bridge Name] = @Bridge", GetDBConnection())
        conn.Parameters.AddWithValue("@Bridge","Test Bridge")
        Search(conn)
        conn.Connection.Close()
        conn.Dispose()
    End If
End If
Begginnerdev 256 Junior Poster

If using the default .NET ListView, which I don't think supports gifs, you will not be able to see any animation.

You can use something like this.

Hope this points you in the right dir. :)

Begginnerdev 256 Junior Poster

Change:

Dim dr As New DataRow = ds.Tables("tblRegCust").Rows.Add

To:

Dim dr As DataRow = ds.Tables("tblRegCust").Rows.Add

And change:

dat = Nothing

To:

da = Nothing

My appologies. This is what happens when you type code on the fly. :)

Begginnerdev 256 Junior Poster

The question is, are all columns from the database present in the list view?

ie: If you have more columns in the ListViewItem than that exists in the ListView - the data will not render.

Begginnerdev 256 Junior Poster

The code snippet:

For i = 0 To ds.Tables(0).Rows.Count - 1
    For j = 0 To ds.Tables(0).Columns.Count - 1
        itemcoll(j) = ds.Tables(0).Rows(i)(j).ToString()
    Next
    Dim lvi As New ListViewItem(itemcoll)
    Me.lvPrinterSetup.Items.Add(lvi)       
Next

Is loading values into a string array, then into a listview item, just like this:

For i = 0 to ds.Tables("MyData").Rows.Count - 1
    With ds.Tables("MyData")
        Dim lvi As New ListViewItem

        lvi.Text = .Rows(i)("PrinterID")
        lvi.SubItems.Add(.Rows(i)("PrinterName"))
        lvi.SubItems.Add(.Rows(i)("PrinterNumber"))
        lvi.SubItems.Add(.Rows(i)("PrinterLocation"))
        lvi.SubItems.Add(.Rows(i)("PrinterAddress"))

        ListView1.Items.Add(lvi)
    End With
Next

It just enumerates on the index, instead of referencing the column name.

Begginnerdev 256 Junior Poster

I know one that you can clean that code up: DataAdapters

For instance:

Private Sub IssueInsert()
    Dim cmd As New SQLCommand("SELECT * FROM registered_cust_tbl",myCon)
    Dim da As New SQLDataAdapter(cmd)
    Dim ds As New DataSet
    Try
        da.Fill(ds,"tblRegCust")

        If IsNothing(ds.Tables("tblRegCust")) = False Then
            Dim dr As New DataRow = ds.Tables("tblRegCust").Rows.Add

            'Put your column names here:
            dr("customer_fname") = firstNameTb.Text.Trim
            dr("customer_lname") = lastNameTb.Text.Trim
            dr("customer_DoB") = DoBtb.Text
            '........

            ds.Tables("tblRegCust").Rows.Add(dr)

            da.UpdateCommand = New SQLCommandBuilder(da).GetUpdateCommand()
            da.Update(ds)
        Else
            MsgBox("Nothing was returned from the table.")
        End If
    Catch ex As Exception
        MsgBox(ex.ToString)
    Finally
        cmd = Nothing
        dat = Nothing
        ds = Nothing
    End Try        
End Sub

This will be protected against SQL injection attacks.

Begginnerdev 256 Junior Poster

Hello my fellow DaniWebers!

I have a question for you!

I have an ASP.Net website that I am currently working on. The problem that I am having is that I want to render the Master page's menu differently for the user types. Here is the catch. I can't use roles, only user names.

I have stared by creating different SiteMaps in the project, and Adding Multiple providers in the Web.config.

The menu is on the Master Page, and is bound with a SiteMapSource. This is a horizontal menu, and not a treeview. (Couple of Google results solved for a treeview.)

The question being; How do I bind the menu programmaticly on load by username? (AD Driven)

As far as I can tell:

User.Identity.Name

Is null for the master page, but I can pass the username in from the default page. (or the login page)

Thanks for any ideas/help!

I posted this in VB.NET because of the code backend, or should I flag to move the post to ASP.NET?

Begginnerdev 256 Junior Poster

Is the application throwing the error on restore, or on the backup code?

Begginnerdev 256 Junior Poster

Have you insured that the ListView is set to Details view, and has columns added to it?

If you have not added columns to it, try this:

For i = 0 To ds.Tables("MyData").Columns.Count
    'This will create a column with a default width of 100.
    lvPrinterSetup.Columns.Add(ds.Tables("MyData").Columns(i).ColumnName, 100)
Next

You also need to check for code that might be clearing the listview.

Begginnerdev 256 Junior Poster

Here is a link that may help.

It is written in C#, but the solution has nothing to do with coding.

Begginnerdev 256 Junior Poster

The safest way to do so, if you have not solved the problem, would be to use Properties.

For Example:

Public Class Form1  
    Public Property TextString As String
        Get
            Return TextBox1.Text
        End Get
        Set(value As String)
            TextBox1.Text = value
        End Set
    End Property    
End Class

Public Class Form2
    Private Sub btnSendTo_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnSendTo.Click
        Form1.TextString = "This is a test."
    End Sub
End Class
TnTinMN commented: something along the lines of great minds think alike ;>) +8
Begginnerdev 256 Junior Poster

Either was is just as effecient as the other. I just learned by using DataSets. It is a personal preference kind of thing.

The advantage a dataset has is that you can reference it and use it later for updating data.

Begginnerdev 256 Junior Poster

Pass your query and parameters into your Search Sub:

Dim Query As String = "SELECT * FROM tblTest WHERE [My Column]=@Value"
Dim Parameters As New Dictionary(Of String, String)



'Fill the dictionary
Parameters.Add("@Value", "ValueToSearchFor")





'Call the Sub
Search(Query, Parameters)



'Sub Declaration


Private Sub Search(ByVal sQuery As String, ByVal dctParameters As Dictionary(Of String, String))
    Try
        Dim conn As OleDbConnection = GetDbConnection()
        bridgenumber = TextBox1.Text.ToString()
        ' Select records.

        'Pass Query in Here
        comm = New OleDbCommand(sQuery, conn)

        For Each k As KeyValuePair(Of String, String) In dctParameters
            comm.Parameters.AddWithValue(k.Key, k.Value)
        Next

        Dim data_reader As OleDbDataReader = comm.ExecuteReader()

        If data_reader.HasRows = True Then
            ListView1.Items.Clear()
            Do While data_reader.Read()
                Dim new_item As New ListViewItem(data_reader.Item("Bridge Number").ToString)
                new_item.SubItems.Add(data_reader.Item("Bridge Name").ToString)
                new_item.SubItems.Add(data_reader.Item("District Name").ToString)
                new_item.SubItems.Add(data_reader.Item("Section Name").ToString)
                new_item.SubItems.Add(data_reader.Item("Road Segment Name").ToString)
                new_item.SubItems.Add(data_reader.Item("Bridge Type").ToString)
                new_item.SubItems.Add(data_reader.Item("Bridge Span").ToString)
                new_item.SubItems.Add(data_reader.Item("Bridge Condition").ToString)
                new_item.SubItems.Add(data_reader.Item("Acquisition Year").ToString)
                new_item.SubItems.Add(data_reader.Item("Evaluation Year").ToString)
                new_item.SubItems.Add(data_reader.Item("End of Design Life Year").ToString)
                new_item.SubItems.Add(data_reader.Item("Bridge Asset Value").ToString)
                ListView1.Items.Add(new_item)
            Loop
        Else
            MsgBox("There is no record in the database", vbCritical, "Bridge Asset Management")
            ListView1.Items.Clear()
        End If
        ' Close the connection.
        data_reader.Close()
        data_reader = Nothing
        comm.Dispose()
        comm = Nothing
        conn.Close()
        conn.Dispose()
        conn = Nothing
    Catch ex As Exception
        MsgBox(ex.ToString)
    End Try
End Sub
Begginnerdev 256 Junior Poster

Are you sure the path is correct?

You can verify it by doing this:

If File.Exists("C:\Users\Abdueie\Desktop\BMS\Bridge Asset Management\Bridge Asset Management\bin\Debug\Adigrat.accdb") Then MsgBox("It is there!") Else MsgBox("Path May Be Wrong!")
Begginnerdev 256 Junior Poster

Is the listview set to view.Details?

You can set this in the designer, and in the code.

As far as loading data goes, the code snippet looks fine to me.

I do not use readers as much though. I use DataSets/DataAdapters.

You can do the same with them by:

Dim da As New SQLDataAdapter(cmd)
Dim ds As new DataSet

da.Fill(ds,"MyData")

IF IsNothing(ds.Tables("MyData")) = False And ds.Tables("MyData").Rows.Count > 0 Then

    For i = 0 to ds.Tables("MyData").Rows.Count - 1
        With ds.Tables("MyData")
            Dim lvi As New ListViewItem

            lvi.Text = .Rows(i)("PrinterID")
            lvi.SubItems.Add(.Rows(i)("PrinterName"))
            lvi.SubItems.Add(.Rows(i)("PrinterNumber"))
            lvi.SubItems.Add(.Rows(i)("PrinterLocation"))
            lvi.SubItems.Add(.Rows(i)("PrinterAddress"))

            ListView1.Items.Add(lvi)
        End With
    Next
End If
Begginnerdev 256 Junior Poster

You will need to run RegSvr32 on the dll to register it on the client machine.

Begginnerdev 256 Junior Poster

You have a few options.

The easiest: ClickOnce deployment.

The next two options are more complicated:

InnoSetup

InstallShield

InnoSetup being a free instal package tool, InstallSheild being Very expensive.

Begginnerdev 256 Junior Poster

Any time you have values being loaded in to memory, you run the risk of slowing down a process.

I suggest a small database backend to store the words/meanings/sample sentences. Then perform a lookup when needed.

For example:

----------------------------------------------------------------
|__________________________tblWords____________________________|
|_____ID_____|______Word ____|______Type______|____Sentence____|
|  Identity  |  VarChar(50)  |  VarChar(100)  |  VarChar(500)  |
----------------------------------------------------------------

This will give you a lookup table, where you can store values similar to this:

0 , abo , Adverb , to come along with sb. Annii ageen ho paze atu si abo mondo.(the duckling is coming with its mother).
1 , abi ,  , to come on behalf of other.

This table will store ALL of your words/definitions.

Then to get the definition, just query the database:

Dim myCon As New OleDBConnection("MyConnectionStringHere") 'See www.ConnectionStrings.com
myCon.Open()
'Assumes words are unique in spelling in database.
Dim da As New OleDBDataAdapter("SELECT * FROM tblWords WHERE Word=@Word",myCon)
da.SelectCommand.Parameters.AddWithValue("@Word",TextBox1.Text)
Dim ds As New DataSet

Try
    da.Fill(ds,"Definitions")
    If ds.Tables("Definitions") IsNot Nothing And ds.Tables("Definitions").Rows.Count > 0 Then
        With ds.Tables("Definitions")
            TextBox2.Text = TextBox1.Text
            TextBox3.Text = .Rows(0)("Type")
            TextBox4.Text = .Rows(0)("Sentence")
        End With
    End If
Catch ex As Exception
    MsgBox(ex.ToString)
End Try

This will force the database to do most of the work, and allow your code to run smoother by removing the HUGE nested if that is there.

joramkaku commented: Thanks a lot for such a beautiful tip. Thanks again +0
Begginnerdev 256 Junior Poster

What do you mean by package?

An Installation Package?

A dll?

Begginnerdev 256 Junior Poster

You are almost there.

Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
    Try
        Dim val1 as Integer = Cint(TextBox1.Text.SubString(0,1))
        Dim val2 as Integer = Cint(TextBox1.Text.SubString(1,1))

        Label1.Text = "First digit:" & TextBox1.Text.Substring(0, 1)
        Label2.Text = "Second digit:" & TextBox1.Text.Substring(1, 1)

        Label3.Text = "Sum is:" & ((val1 *= val1) + (val2 *= val2))    
    Catch ex As Exception
        MsgBox(ex.ToString)
    End Try
End Sub
Begginnerdev 256 Junior Poster

What it sounds like you want is a dataset to use, or threaded process to upload.

The dataset being the easier of the two.

Private Function GetDataFromFile(ByVal sPath as String) As List(Of List( OfString))
    Try
        Dim sr As New StreamReader(sPath)
        Dim lstStrings As New List(Of List(Of String))

        Do While sr.Peek <> -1
            'This will split on the , characters.
            lstStrings.Add(sr.ReadLine.Split(",").ToList)
        End While

        Return lstStrings
    Catch ex As Exception
        MsgBox(ex.ToString)
        Return New List(Of String)
    End Try
End Function

Private Function FillDataSet(ByVal lstStrings As List(Of List(Of String))) As DataSet
    Try
        Dim da As New OleDBDataAdapter("SELECT * FROM MyTable",myCon) 'myCon is an OleDBConnection
        Dim ds As New DataSet

        da.Fill(ds,"myTable")

        If Not IsNothing(ds.Tables("myTable")) Then
            For i = 0 to lstStrings.Count - 1
                Dim dr As DataRow = ds.Tables("myTable").Rows.Add()

                'For columns that do not allow NULL
                dr("Column1") = IIF(IsDBNull(lstStrings(i)(0)),TrueValue,FalseValue)
                                                       '^ 1st column of the n'th list.
                'For columns that allow NULL
                dr("Column2") = lstStrings(i)(1) '2nd column of the n'th list.
            Next

            Return ds
        Else
            Return New DataSet
        End If
    Catch ex As Exception
        MsgBox(ex.ToString)
        Return New DataSet
    End Try
End Function

Now, with that being said, you will have a dataset containg all of the values you wanted to pass in and update.

To view them, just step through:

Dim iCurrentRecord As Integer = 0


Private Sub NextButton_Click(ByVal Sender As Object, ByVal e As EventArgs) Handles NextButton.Click
    Try
        If iCurrentRecord + 1 <= ds.Tables("myTable").Rows.Count - 1 Then
            LoadCurrent(iCurrentRecord + 1)
            iCurrentRecord += 1
        End If
    Catch ex As Exception
        MsgBox(ex.ToString)
    End Try …
Begginnerdev 256 Junior Poster

This sounds A LOT like a class project.

As far as code goes, we can't help you until you show effort yourself.

Do you have any code thus far?

Begginnerdev 256 Junior Poster

Are you using a custom type that is declared by you, or auto generated by a dataset added to the project?

Begginnerdev 256 Junior Poster

An update statement would look something like this:

cmd = New OleDBCommand("UPDATE Adigrat SET [Bridge Number]=@Value",con)
cmd.Parameters.AddWithValue("@Value",ValueToUpdate)

cmd.ExecuteNonQuery()
Begginnerdev 256 Junior Poster

Have you tried an update on the whole ds?

for example:

CancelTemplateTableAdapter.UpdateCommand = New SQLCommandBuilder(CancelTemplateTableAdapter).GetUpdateCommand
CancelTemplateTableAdapter.Update(CancelTemplate)
Begginnerdev 256 Junior Poster

No problem friend!

Please do not forget to mark the question as solved.

Begginnerdev 256 Junior Poster

I suspect the "Bridge Number" part of your query.

You may have to wrap your field name with [ brakets.

For example:

cmd = New OleDBCommand("DELETE FROM Adigrat WHERE [Bridge Number]=@BridgeNumber",conn)
cmd.Parameters.AddWithValue("@BridgeNumber",bridgenumber)

cmd.ExecuteNonQuery()
Begginnerdev 256 Junior Poster

Where is the null exception being thrown?

I am assuming it is from the "YourStringValueHere"

Begginnerdev 256 Junior Poster

You could do something like the following:

e.Graphics.DrawString(TextBox1.Text,f,br,50,50)

If you wanted to pull them in from a dataset, you could do something like this:

Dim da As New OleDBDataAdapter("SELECT * FROM myTable",myCon)
Dim ds As New DataSet

da.Fill(ds,"MyTable")

If IsNothing(ds.Tables("MyTable")) = False And ds.Tables("MyTable").Rows.Count > 0 Then
   For i = 0 to ds.Tables("MyTable").Rows.Count - 1
       With ds.Tables("MyTable")
           e.Graphics.DrawString(.Rows(i)("MyColumn1"),f,br,50,50)
           'Just Remember to Increase the Y on the DrawString so that you are not writing everything in one spot.   
       End With
   Next
End If
Begginnerdev 256 Junior Poster

You could loop through the values and check if they are equal:

For i As Integer = 0 To dataGridView1.Rows.Count - 1
    For j As Integer = 0 To dataGridView1.Columns.Count - 1
        If IsNothing(dataGridView1.Rows(i).Cells(j).Value) = False And YourStringValueHere = dataGridView1.Rows(i).Cells(j).Value.ToString() Then

            'Item found

            Exit For
        End If
    Next
Next
Begginnerdev 256 Junior Poster

Here is an article on watching a file system. (Which sounds like what you want to do.)

Begginnerdev 256 Junior Poster

When I first started programming, I had a huge task to tackle using AD.

I used this for a reference to get me started.

You can use the My.User.Name to retreive the user's login name.

Begginnerdev 256 Junior Poster

If you are only wanting to capture keystrokes while your application is running, then look into keydown.

If not, look into using hooks.

Begginnerdev 256 Junior Poster

You can make use of the DateName and DatePart functions.

Begginnerdev 256 Junior Poster

There will be many different options for data manipulation.

You can use bound controls.

You can use GridViews.

You can use ListViews.

You can use Reporting.

Here is a very good article you might want to read. It will cover the basic concepts of databinding.

I hope this helps!

TnTinMN commented: good article. thanks +8
Begginnerdev 256 Junior Poster

What exception is being thrown?

You have never stated it.

Begginnerdev 256 Junior Poster

Be sure to reference the library in the project.

Go to My Project > References > Add New > Navigate to the correct verison (14.0 I think) then add.