MrBurns Posted November 9, 2003 Posted November 9, 2003 I have a TextBox with Array displayed in it (few lines of information). Now I need to take each separate line of my info from this TextBox and make each separate line as a string, so I can insert it into SQL Database. How can I do that? Please help, I need it done urgently..:( Quote
Administrators PlausiblyDamp Posted November 9, 2003 Administrators Posted November 9, 2003 How is it being stored in the database? Seperate fields per line? You can get at each line in the textbox through the lines property, each item in the collection is a seperate line from the textbox. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
MrBurns Posted November 9, 2003 Author Posted November 9, 2003 I tried Lines property, it didn't work for me.. On the other hand this array forks just fine. All I need is to get Value(which is text array from textbox) and put it into my StoredProcedure Value. It seems so easy but doesn't work. I come up with things like "..must implement IConvertible" "Index is outside of bounds of the array" or data from the textbox gets truncated on the way and it inserts empty line....... Quote
Administrators PlausiblyDamp Posted November 9, 2003 Administrators Posted November 9, 2003 What does the parameter list for the stored proc look like? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
MrBurns Posted November 9, 2003 Author Posted November 9, 2003 cmd1.Parameters.Add("@1par", SqlDbType.VarChar, 200) cmd1.Parameters("@1par").Value = ?? cmd1.Parameters.Add("@2par", SqlDbType.VarChar, 200) cmd1.Parameters("@2par").Value = ?? cmd1.Parameters.Add("@3par", SqlDbType.VarChar, 200) cmd1.Parameters("@3par").Value = ?? Those question marks, I don't know what to put insted of them.. I have to get the values from my Array, which is inside the textBox already Quote
Administrators PlausiblyDamp Posted November 9, 2003 Administrators Posted November 9, 2003 The procedure has only three paramters - correct? How many lines will the textbox have? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
MrBurns Posted November 9, 2003 Author Posted November 9, 2003 Yes, 3 parameters There are also 3 TextBoxes, each one has text for each parameter. But .. every time I run my App, those TextBoxes get different ammount of text in them. Each TextBox has few lines of text in it Quote
Administrators PlausiblyDamp Posted November 9, 2003 Administrators Posted November 9, 2003 (edited) Could you not just put the contents of each textbox as a parameter to the proc without worrying about each line? Or is there a problem when passing in multiple lines as a single parameter? Edited March 7, 2006 by PlausiblyDamp Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
MrBurns Posted November 9, 2003 Author Posted November 9, 2003 I tried putting any contets of my text box(all of it) to start off with, and I never got it to work... At this stage of my App I am totaly confused :( Quote
Administrators PlausiblyDamp Posted November 9, 2003 Administrators Posted November 9, 2003 Could you post your existing code and the errors you are getting? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
MrBurns Posted November 9, 2003 Author Posted November 9, 2003 .......... Dim oRegex As Regex Dim oRegex1 As Regex Dim oRegex2 As Regex Dim omatch As Match Dim omatch1 As Match Dim omatch2 As Match Dim omatches As MatchCollection Dim omatches1 As MatchCollection Dim omatches2 As MatchCollection Dim reg As String Dim reg1 As String Dim reg2 As String reg = "((https?|ftp)\://((\[?(\d{1,3}\.){3}\d{1,3}\]?)|(([-a-zA-Z0-9]+\.)+[a-zA-Z]{2,4}))(\:\d+)?(/[-a-zA-Z0-9._?,'+&%$#=~\\]+)*/?)" reg1 = "[\w-]+(?:\.[\w-]+)*@(?:[\w-]+\.)+[a-zA-Z]{2,7}" reg2 = txtMeta.Text oRegex = New Regex(reg) oRegex1 = New Regex(reg1) oRegex2 = New Regex(reg2) Dim sContent sContent = txtHTML.Text omatches = oRegex.Matches(sContent) omatches1 = oRegex1.Matches(sContent) omatches2 = oRegex2.Matches(sContent) For Each omatch In omatches 'Displays URL's txtHTTP.Text = txtHTTP.Text & vbCrLf & "" & vbCrLf & omatch.Value Next For Each omatch1 In omatches1 'Displays Emails txtEmails.Text = txtEmails.Text & vbCrLf & "" & vbCrLf & omatch1.Value Next For Each omatch2 In omatches2 'Displays MetaData txtMetares.Text = txtMetares.Text & vbCrLf & "" & vbCrLf & omatch2.Value Next '1 Array Dim arurl As String() = Split(txtHTTP.Text, " ") Dim I1 As Integer For I1 = 0 To arurl.GetUpperBound(0) txtArrays1.Text = (arurl(I1)) Next '2 Array Dim aremail As String() = Split(txtEmails.Text, " ") Dim I As Integer For I = 0 To aremail.GetUpperBound(0) txtArrays.Text = (aremail(I)) Next '3 Array Dim armeta As String() = Split(txtMetares.Text, txtMeta.Text) Dim I2 As Integer For I2 = 0 To armeta.GetUpperBound(0) txtArrays2.Text = (armeta(I2)) Next ''RUN SQL SP Try Dim oSQLConn1 As New SqlConnection("Data Source=COMPUTER;" & _ "Initial Catalog=localDB;" & _ "Integrated Security=SSPI") Dim cmd1 As New SqlCommand("mySP", oSQLConn1) cmd1.CommandType = CommandType.StoredProcedure oSQLConn1.Open() Dim sdr1 As SqlDataReader cmd1.Parameters.Add("@addurl", SqlDbType.VarChar, 200) cmd1.Parameters("@addurl").Value = ?? cmd1.Parameters.Add("@addemail", SqlDbType.VarChar, 200) cmd1.Parameters("@addemail").Value = ?? cmd1.Parameters.Add("@meta", SqlDbType.VarChar, 200) cmd1.Parameters("@meta").Value = ?? sdr1 = cmd1.ExecuteReader Catch ex1 As System.Exception MsgBox(ex1.ToString()) Catch ex As System.Data.SqlClient.SqlException MsgBox(ex.ToString()) Finally End Try I just need those values from TextBoxes (txtArrays1, txtArrays, txtArrays2) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.