I am having trouble with textbox multiline when it store to Access database and returning in gridview show one chunk of string. Is there anyway to place each data into each own row?
Input:

google

yahoo

msn

Output:

www.google.com

www.yahoo.com

www.msn.com


But right now it is give me www.googleyahoomsn.com

Here is my code:

Sub btnSubmitClicked(ByVal S As Object, ByVal e As EventArgs)

        Dim conn1 As New OleDbConnection("Provider=Microsoft.jet.oledb.4.0;Data Source=C:\Data\audit.mdb")
        Dim strInsert As String
        Dim strDelete As String
        Dim cmdInsert As OleDbCommand
        Dim cmdDelete As OleDbCommand

        TextBox1.TextMode = TextBoxMode.MultiLine
        TextBox1.MaxLength = 15

        strInsert = "Insert into audit(fldLocation) values ('" & TextBox1.Text & "')"
        strDelete = "DELETE * FROM audit "
        cmdInsert = New OleDbCommand(strInsert, conn1)
        cmdDelete = New OleDbCommand(strDelete, conn1)
        conn1.Open()

            
        cmdDelete.ExecuteNonQuery()

        cmdInsert.ExecuteReader()


        conn1.Close()
        Response.Redirect("audit.aspx")


    End Sub
End Class

I am having trouble with textbox multiline when it store to Access database and returning in gridview show one chunk of string. Is there anyway to place each data into each own row?
Input:

google

yahoo

msn

Output:

www.google.com

www.yahoo.com

www.msn.com


But right now it is give me www.googleyahoomsn.com

Here is my code:

Sub btnSubmitClicked(ByVal S As Object, ByVal e As EventArgs)

Dim conn1 As New OleDbConnection("Provider=Microsoft.jet.oledb.4.0;Data Source=C:\Data\audit.mdb")
Dim strInsert As String
Dim strDelete As String
Dim cmdInsert As OleDbCommand
Dim cmdDelete As OleDbCommand

TextBox1.TextMode = TextBoxMode.MultiLine
TextBox1.MaxLength = 15

strInsert = "Insert into audit(fldLocation) values ('" & TextBox1.Text & "')"
strDelete = "DELETE * FROM audit "
cmdInsert = New OleDbCommand(strInsert, conn1)
cmdDelete = New OleDbCommand(strDelete, conn1)
conn1.Open()


cmdDelete.ExecuteNonQuery()

cmdInsert.ExecuteReader()


conn1.Close()
Response.Redirect("audit.aspx")


End Sub
End Class

Hi there

I assume that you have " " single blanck space as separator in ur input. pls. follow the code below...

Private Function DoStuff() As String
        Dim arr As Array
        Dim str As String = "yahoo google gmail" 'i assume your input with singe space 
        Dim strResult As String

        arr = str.Split(" ")

        For i As Integer = 0 To UBound(arr)
            strResult += "www." & arr(i) & ".com" & ", "
        Next
        Return strResult

    End Function

'use it dostuff function in your query
strInsert = "Insert into audit(fldLocation) values ('" & DoStuff.ToString & "')"

Pls. mark as solved if it helps you!!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.