0

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

Edited by peter_budo: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks)

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by reach_yousuf
0

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

Edited by reach_yousuf: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.