textbox multiline Access VB

Please support our ASP.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Oct 2009
Posts: 1
Reputation: jumping45 is an unknown quantity at this point 
Solved Threads: 0
jumping45 jumping45 is offline Offline
Newbie Poster

textbox multiline Access VB

 
0
  #1
Oct 12th, 2009
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:

  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)
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 66
Reputation: reach_yousuf is an unknown quantity at this point 
Solved Threads: 12
reach_yousuf reach_yousuf is offline Offline
Junior Poster in Training
 
0
  #2
Oct 13th, 2009
Originally Posted by jumping45 View 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:

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


  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.
Yousuf
Software Developer
Reply With Quote Quick reply to this message  
Reply

Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC