944,119 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Unsolved
  • Views: 989
  • ASP.NET RSS
Oct 12th, 2009
0

textbox multiline Access VB

Expand Post »
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:

asp.net Syntax (Toggle Plain Text)
  1. Sub btnSubmitClicked(ByVal S As Object, ByVal e As EventArgs)
  2.  
  3. Dim conn1 As New OleDbConnection("Provider=Microsoft.jet.oledb.4.0;Data Source=C:\Data\audit.mdb")
  4. Dim strInsert As String
  5. Dim strDelete As String
  6. Dim cmdInsert As OleDbCommand
  7. Dim cmdDelete As OleDbCommand
  8.  
  9. TextBox1.TextMode = TextBoxMode.MultiLine
  10. TextBox1.MaxLength = 15
  11.  
  12. strInsert = "Insert into audit(fldLocation) values ('" & TextBox1.Text & "')"
  13. strDelete = "DELETE * FROM audit "
  14. cmdInsert = New OleDbCommand(strInsert, conn1)
  15. cmdDelete = New OleDbCommand(strDelete, conn1)
  16. conn1.Open()
  17.  
  18.  
  19. cmdDelete.ExecuteNonQuery()
  20.  
  21. cmdInsert.ExecuteReader()
  22.  
  23.  
  24. conn1.Close()
  25. Response.Redirect("audit.aspx")
  26.  
  27.  
  28. End Sub
  29. End Class
Last edited by peter_budo; Oct 13th, 2009 at 2:20 pm. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks)
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
jumping45 is offline Offline
1 posts
since Oct 2009
Oct 13th, 2009
0
Re: textbox multiline Access VB
Click to Expand / Collapse  Quote originally posted by jumping45 ...
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...


ASP.NET Syntax (Toggle Plain Text)
  1.  
  2.  
  3. Private Function DoStuff() As String
  4. Dim arr As Array
  5. Dim str As String = "yahoo google gmail" 'i assume your input with singe space
  6. Dim strResult As String
  7.  
  8. arr = str.Split(" ")
  9.  
  10. For i As Integer = 0 To UBound(arr)
  11. strResult += "www." & arr(i) & ".com" & ", "
  12. Next
  13. Return strResult
  14.  
  15. End Function
  16.  
  17. 'use it dostuff function in your query
  18. strInsert = "Insert into audit(fldLocation) values ('" & DoStuff.ToString & "')"

Pls. mark as solved if it helps you!!!
Last edited by reach_yousuf; Oct 13th, 2009 at 4:25 am.
Reputation Points: 12
Solved Threads: 38
Junior Poster
reach_yousuf is offline Offline
194 posts
since Sep 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP.NET Forum Timeline: Onclick event method only works once.
Next Thread in ASP.NET Forum Timeline: Need help for Regular Expression





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC