|
Hi,
Does anyone know what this following regular expression would interpret as?
Regex re=new Regex("((?<field>[^\",\\r\\n]*)|\"(?<field>([^\"]|\"\")*)\")(,|(?<rowbreak>\\r\\n|\\n|$))");
Many thanks for your time.
|
|
|
|
|
((?[^\",\\r\\n]*)|\"(?([^\"]|\"\")*)\")(,|(?<rowbreak>\\r\\n|\\n|$))
Basically (...)s create a group which can be retrieved later from the results if it has a (?...) then it is simply used as grouping in the regex and is not output to the results.
Pattern 1: The 1st bracket then is looking any characters bar for a quote (") followed by a comma (,) and carriage return / line feed (\r\n). It wants one or more of these consecutively.
Pattern 2: The 2nd bracket is looking for any characters except a quote or a two quotes, again matching zero or more of these consecutively.
Pattern 3: The 3rd bracket(s) are looking for a comma or (a carriage return, line feed or a new line or the end of the string).
So in summary it's matching Pattern 1 or a quote followed by Pattern 2 and 3.
Hope that explains it a bit, it's quite difficult to put into words, just remember that brackets act like grouping constructs like in any programming language, except here unless they have a ? following the opening parenthesis (? then the group is output into the results.
|
|
|
|
|
It is comma delimited csv file that is being read. To change the comma to a tilda(~) delimited file, would changing in those two places a comma occurs to tilda work?
Thanks.
|
|
|
|
|
Hi everyone:
I'm new in .net web programming, and I really need help on this, because i have to finish this work by next week, and by now, I am getting desperate!!!! My issue is that I have a web site, kind of a point of sale (POS), but I need users to print tickets on their local printers. I dont know how to do this, since my app doesn't "see" any network printer. I am printing directly to the printer, not using any reports. Please I would really appreciate any solution, even any suggestion on how to make it better. Thanks in advance...
|
|
|
|
|
Just generate a simple HTML "report" and then you can use javascript or tell them to print the page themselves. That's what everyone else does.
|
|
|
|
|
You can't see their printer, you can't see anything on their PC. You can give them a form to print, but you can't know they will print it, or even that they have a printer.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi,
I have two apsx pages. In the first aspx page I have one gridView and a linkbutton under gridview. When the user clicks on LinkButton it will take you to the next aspx page. In the second aspx page I have 2 text boxes and one button Insert. The user enter some data into text boxes and clicking on Insert button will take him to the first aspx page and fill the textboxes data to Gridview.
In the first aspx page my code is like this:
Page_Load()
{
GridView1.DataSource = (System.Data.DataTable)Session["dta"];
GridView1.DataBind();
dta = (System.Data.DataTable)CreateDataTableA();
if (!IsPostBack)
{
Session["dta"] = dta;
}
}
//This is for link button click event.
protected void LBAddPartner_Click(object sender, EventArgs e)
{
Response.Redirect("PartnerDistrict.aspx");
}
protected System.Data.DataTable CreateDataTableA()
{
System.Data.DataTable aTable = new System.Data.DataTable();
DataColumn dtCol;
// Create ID column and add to the DataTable.
dtCol = new DataColumn();
dtCol.DataType = System.Type.GetType("System.String");
dtCol.ColumnName = "District_ID";
dtCol.AutoIncrement = false;
dtCol.Caption = "District_ID";
dtCol.ReadOnly = false;
dtCol.Unique = false;
// Add the column to the DataColumnCollection.
aTable.Columns.Add(dtCol);
// Create Name column and add to the table
dtCol = new DataColumn();
dtCol.DataType = System.Type.GetType("System.String");
dtCol.ColumnName = "District_Name";
dtCol.AutoIncrement = false;
dtCol.Caption = "District_Name";
dtCol.ReadOnly = false;
dtCol.Unique = false;
aTable.Columns.Add(dtCol);
return aTable;
}
In the second page:
//Insert button click:
protected void Button1_Click(object sender, EventArgs e)
{
dta = (System.Data.DataTable)Session["dta"];
DataRow dr = dta.NewRow();
dr[0] = txtboxDID.Text.ToString();
dr[1] = txtBoxDName.Text.ToString();
dta.Rows.Add(dr);
//Response.Redirect("Default.aspx");
Response.Redirect("Default.aspx");
txtboxDID.Text = "";
txtBoxDName.Text = "";
}
My problem is I the gridview (datatable) showing only the last inserted record only . WhereI mean in which event I have to put this line Session["dta"]=dta in first aspx page to persist all records.
Thanks in advance
|
|
|
|
|
The line doesn't matter, if it's in the session, it's in the session. If the data comes from your database, a better solution is to pass over an Id which can be used to reproduce the database query to get the data down again on your new page. Another option is cross page postback, and pulling the data out of viewstate.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Any ever have any trouble using an updatePanel with RadioButtonLists? I am getting it to update once without posting back to the server using async postback but once I click on the other radiobutton it doesn't run the same set of code again. If you know of any articles to read that would be great!
Thanks,
Cisco
|
|
|
|
|
I am building datasets at run time from asn asp.net c# web page. My chalenge is one of my stored proceedures has to harvest an extremely large dataset depending on the date range selected. My question is how to I set the progress of the stored proceedure?
Here is a scenario
if the data range is this month or this week the proceedure will run in a small period of time maybe 15 seconds. But if they choose to run the dataset going back one full year then it will take atleast 5 mins to generate the appropriate data.
How to I make the asp.net webpage wait until that proceedure is done?
Thanks
|
|
|
|
|
wait how ? Your page is going to timeout in five minutes. Your best bet is to have another process, such as a windows service, do the stored proc call, and have your page auto postback, or use AJAX, to work out when the process has ended, and the data can be loaded by the page.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi,
I added an attribute to the items of a DropDownList.
cbBudget.Items(0).Attributes.Add("bLocked", true)
cbBudget.Items(1).Attributes.Add("bLocked", false)
Now I want to get the value of the selected item in the DropDownList using javascript.
I tried something like this:
document.getElementById("cbBudget").selectedItem.getAttribute("bLocked")
but it doesn't work.
The source looks like this:
Class1
Class 2
Thank you for your suggestions.
|
|
|
|
|
|
This also worked
var index =document.getElementById("cbBudget").selectedIndex;
alert(document.getElementById("cbBudget").options[index].bLocked)
Thanks Ben
|
|
|
|
|
Thanks Ben,
That is a great article, now I don't have to Alert("I am here"); anymore.
Martin
|
|
|
|
|
Glad you liked it. Without it I don't think I would have gotten into javascript. Too much like the old Cobol programming I used to have to do with the "I am here" to debug.
Ben
|
|
|
|
|
Hi
I have built a simple page which will should send a persons firstname and lastname to mysql database, i am not sure how to code the submit button as i obviously need it to call my method for sending data to the server based on the input in my text boxes.
Any suggestions, i recognise is probably fundamental but am newbie to asp and not got much web development background
This is what I have
<%@ Page Language="VB" debug="true" %>
<%@ Import Namespace = "System.Data" %>
<%@ Import Namespace = "MySql.Data.MySqlClient" %>
<script language="VB" runat="server">
Sub page_load()
End Sub
''' <summary>
''' Page_load
''' Recognised by ASP and must be provided on loading of page.
'''
''' Creates connection to database, passes stored procedure into test database
''' and fills a table, which is showing in web browser
''' </summary>
''' <param name="sender"></param>
''' <param name="e"></param>
''' <remarks></remarks>
Sub sendData(ByVal sender As Object, ByVal e As EventArgs)
'Create connection string to pass database, string holds login information to mySQL,
Dim connectionString As String
connectionString = "Server=; uid=; pwd=;database=;"
'Builds .net mysql connection and passes connection string into method
Dim connection As New MySqlConnection(connectionString)
'Open connection to DB
connection.Open()
'Create mySql command string for passing query or SPROC(Stored Procedure)
Dim cmdString As New MySqlCommand
'Set Command to equal mySql connection,t so can pass SQL query
cmdString.Connection = connection
'Set command string to equal SPROC
cmdString.CommandText = "insertmessage"
'ONLY PLACE THIS IF SPROC, sets the command to a SPROC
cmdString.CommandType = CommandType.StoredProcedure
Dim param As New MySqlParameter
param = cmdString.Parameters.Add("param1", SqlDbType.VarChar, 50)
param.Direction = ParameterDirection.Input
param.Value = txtFirstName.Text
param = cmdString.Parameters.Add("param2", SqlDbType.VarChar, 50)
param.Direction = ParameterDirection.Input
param.Value = txtLastName.Text
cmdString.ExecuteNonQuery()
End Sub
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Untitled Page</title>
<script language="vbscript" type="text/vbscript">
</script>
</head>
<body>
<form id="form1" runat="server">
ENTER FIRSTNAME<asp:TextBox runat="server" ID="txtFirstName">
</asp:TextBox><br /><br />
ENTER LAST NAME
<asp:TextBox runat="server" ID="txtLastName"></asp:TextBox>
<asp:Button runat="server" ID="submit" Text="Submit" />
</form>
</body>
</html>
|
|
|
|
|
Other than hard coding your connection string, rather than placing it in the web.config file, I think you've got the right idea.
only two letters away from being an asset
|
|
|
|
|
Two things:
1) It looks as though you are not using Visual Studio, but have your server code inline - ie in the same file - as you have pasted it here. In this case you need to let the page know which procedure is to be associated with the button click event. Like this:
<asp:Button runat="server" ID="submit" Text="Submit" onclick="sendData" />
2) Within your sendData procedure, you must remember to close the database connection after use. Really, you ought to wrap the code in a try...catch...end try block - something like:
try
connection.Open()
' do your db stuff...
connection.CLose()
catch
If connection.State = ConnectionState.Open Then connection.Close()
end try
cheers
Fred
|
|
|
|
|
I have made the necessary changes as you have said above, it jus keeps falling through to the catch statement tho
any more suggestions?
I have debugged and it seems to go thru as expeced also
<%@ Page Language="VB" debug="true" %>
<%@ Import Namespace = "System.Data" %>
<%@ Import Namespace = "MySql.Data.MySqlClient" %>
<script language="VB" runat="server">
Sub page_load()
End Sub
''' <summary>
''' Page_load
''' Recognised by ASP and must be provided on loading of page.
'''
''' Creates connection to database, passes stored procedure into test database
''' and fills a table, which is showing in web browser
''' </summary>
''' <param name="sender"></param>
''' <param name="e"></param>
''' <remarks></remarks>
Sub sendData(ByVal sender As Object, ByVal e As EventArgs)
Try
'Create connection string to pass database, string holds login information to mySQL,
Dim connectionString As String
connectionString = "Server=localhost; uid=jshort; pwd=oasisarab;database=test;"
'Builds .net mysql connection and passes connection string into method
Dim connection As New MySqlConnection(connectionString)
'Open connection to DB
connection.Open()
'Create mySql command string for passing query or SPROC(Stored Procedure)
Dim cmdString As New MySqlCommand
'Set Command to equal mySql connection,t so can pass SQL query
cmdString.Connection = connection
'Set command string to equal SPROC
cmdString.CommandText = "insertmessage"
'ONLY PLACE THIS IF SPROC, sets the command to a SPROC
cmdString.CommandType = CommandType.StoredProcedure
Dim param As New MySqlParameter
param = cmdString.Parameters.Add("param1", SqlDbType.VarChar, 50)
param.Direction = ParameterDirection.Input
param.Value = txtFirstName.Text
param = cmdString.Parameters.Add("param2", SqlDbType.VarChar, 50)
param.Direction = ParameterDirection.Input
param.Value = txtLastName.Text
cmdString.ExecuteNonQuery()
connection.Close()
Catch
MsgBox("Broken")
End Try
End Sub
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Untitled Page</title>
<script language="vbscript" type="text/vbscript">
</script>
</head>
<body>
<form id="form1" runat="server">
ENTER FIRSTNAME<asp:TextBox runat="server" ID="txtFirstName">
</asp:TextBox><br /><br />
ENTER LAST NAME
<asp:TextBox runat="server" ID="txtLastName"></asp:TextBox>
<asp:Button runat="server" ID="submit" Text="Submit" onclick="sendData" />
</form>
</body>
</html>
|
|
|
|
|
Add a literal control to the page (anywhere)
<asp:Literal runat="server" id="litErr" />
Then replace the catch bit with
catch ex as exception
litErr.Text = ex.Message
That should give you a better idea of where the error is...
cheers
Fred
|
|
|
|
|
on debugging it says that my parameter thats being passed to the stored procedure isn't defined, which i don't understand as i have it defined within the procedure.
This is the code from my procedure
CREATE DEFINER=`myusername`@`localhost` PROCEDURE `InsertMessage`(IN param1 VARCHAR(50), IN param2
VARCHAR(50))
BEGIN
INSERT INTO names(firstName, lastname)
VALUES(param1,param2);
END
|
|
|
|
|
Don't paramater names in SP's have to start with an @ sign? I think so...
Add these to your SP and don't forget to amend your vb code accordingly...
Fred
|
|
|
|
|
Hi All,
Please help me...
I want Import and Export data from excel or access to Sql Server from software
Language: asp.net using Vb
version:.Net 2005
Thank you..
|
|
|
|
|
Are you asking for help in doing this or posting a job requirement?
If the former, what have you done so far? If the latter, wrong forum.
only two letters away from being an asset
|
|
|
|