|
Are you talking about updating the date format the way it is stored in the database? Or when you are retrieving it?
Also what is the data type of your date column is it varchar or DateTime?
If you just want to change the date format when retrieving the data then something like this will work:
SELECT
Convert(varchar, DATEPART(yyyy, UploadDate)) + '/' +
Convert(varchar, DATEPART(mm, UploadDate)) + '/' +
Convert(varchar, DATEPART(dd, UploadDate)) as MyNewFormat
FROM
dbo.[MytableName]
*Change the MytableName to your table and UploadeDate to your column name
hth
|
|
|
|
|
select convert(varchar,columnname,111) from myTable
I Love T-SQL
|
|
|
|
|
Its throwing up an OleDbException:
'Undefined function 'Convert' in expression.'
Any ideas?
|
|
|
|
|
Are you using SQL Server database or MS Access database?
I Love T-SQL
|
|
|
|
|
SQL 2005
Although im trying to do the convert on when uploading an Excel sheet to SQL2005 using BulkCopy.
See below:
<code>protected void Page_Load(object sender, EventArgs e)
{
// Connection String to Excel Workbook
//string excelConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=BLAH\qs_upload.xls;Extended Properties=""Excel 8.0;HDR=YES;""";
string excelConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=BLAH\qs_upload.xls;Extended Properties=""Excel 8.0;HDR=YES;""";
// Create Connection to Excel Workbook
using (OleDbConnection connection = new OleDbConnection(excelConnectionString))
{
OleDbCommand command = new OleDbCommand("Select * FROM [quality_standard$]", connection);
//OleDbCommand command = new OleDbCommand("Select qs_Id, qs_Organisation, Convert(varchar,qs_Start,111), qs_End FROM [quality_standard$]", connection);
connection.Open();
// Create DbDataReader to Data Worksheet
using (OleDbDataReader dr = command.ExecuteReader())
{
// SQL Server Connection String
string sqlConnectionString = "REMOVED"
// Bulk Copy to SQL Server
using (SqlBulkCopy bulkCopy = new SqlBulkCopy(sqlConnectionString))
{
bulkCopy.DestinationTableName = "tbl_QualityStandard";
bulkCopy.WriteToServer(dr);
}
}
}
}</code>
|
|
|
|
|
Hi,
I have an aspx page that contains a control1, which contains another control (I call it, control2). My control2 contains a div (chartdiv) inside other div (chart). My chartdiv displays a graphic (everything done by Javascript) and onclick of the graphic I want to display other page. For that I put my graphic div (which is, chartdiv) inside other div (which is, chart) that allows to me click and open a new page. But my chart is always aligned to right and its not 100% correctly sized. Here is my code that I was refering:
control2 code:
The chart will appear within this DIV. This text will be replaced by the chart.
code behind code:
string IframeSrc = _urlHelper.HandleRootOperator("~/frm_statistic.aspx") + "?pubId=" + _pubId;
chart.Attributes.Add("onclick", "callLinksPage('" + IframeSrc + "','" + "Detailed Statistics for:"+this.State.PublicationTitle + "','760','570');");
Can anyone tell me can't I click my grpahic and open a new page? Is my code works ? or Is there other way to do this.
Thanks.
|
|
|
|
|
It will be helpfull if you right click ur page and copy and paste the HTML so we can see how the page is being rendered.
|
|
|
|
|
Complete Traffic Statistic
|
function LoadChart()
{
//alert(DataLink)
var myChart = new FusionCharts(ChartLink, "myChartId", "198", "135", "0", "0");
myChart.setDataURL(escape(DataLink));
myChart.render("chartdiv");
}
function getTimeForURL()
{
var dt = new Date();
var strOutput = "";
strOutput = dt.getHours() + "_" + dt.getMinutes() + "_" + dt.getSeconds() + "_" + dt.getMilliseconds();
return strOutput;
}
The chart will appear within this DIV. This text will be replaced by the chart.
LoadChart()
|
|
|
|
|
|
|
I dont see the html tags i think its blocked by the editor. When you are posting HTML tags there is an option below the editor "Ignore HTML tags in this message (good for code snippets)" I think if you click that, it will allow you to post the HTML source code.
HTH
|
|
|
|
|
<code><tr>
<td class="tdCRF">
<div class="divStatistics">
<b> <table cellpadding="0" cellspacing="0" width="100%" class="tblStatistics" id="tblStatistics">
<tr>
<td align="left" colspan="2">
<a id="ctl00_RightColumn_WucCRF1_aDisplayStat" title="Detailed Statistic for: HyperNet Configuration File Description" class="handPointer" onclick="callLinksPage('/doXtop/frm_statistic.aspx?pubId=4a095bf','Detailed Statistic for: HyperNet Configuration File Description','760','570');"><strong>
Complete Traffic Statistic</strong> </a>
</td>
</tr>
<tr>
<td colspan="2">
<table cellpadding="0" cellspacing="0" width="100%">
<tr>
<td style="width:100%">
<script type="text/javascript">
function LoadChart()
{
//alert(DataLink)
var myChart = new FusionCharts(ChartLink, "myChartId", "198", "135", "0", "0");
myChart.setDataURL(escape(DataLink));
myChart.render("chartdiv");
}
function getTimeForURL()
{
var dt = new Date();
var strOutput = "";
strOutput = dt.getHours() + "_" + dt.getMinutes() + "_" + dt.getSeconds() + "_" + dt.getMilliseconds();
return strOutput;
}
</script>
<div id="ctl00_RightColumn_WucCRF1_WucStatistics1_chart" class="handPointer" style="width:100%" onclick="callLinksPage('/doXtop/frm_statistic.aspx?pubId=4a095bf','Detailed Statistics for:HyperNet Configuration File Description','760','570');">
<div id="chartdiv">
The chart will appear within this DIV. This text will be replaced by the chart.
</div>
</div>
<script type="text/javascript">
LoadChart()
</script>
</td>
</tr>
</table>
</td>
</tr>
</table> </b>
</div>
</td>
</tr>
</table>
</div>
</td>
</tr>
</table></code>
|
|
|
|
|
ok, so i'm messing around seeing what i can do with the different controls (i started doing ASP last monday ^_^) and i think i pretty much have the basics down. problem is, i can't find any way to pass an argument from a checkbox.
Default.aspx:
<code><asp:CheckBox runat="server"
ID="chkFirst" AutoPostBack="true"
OnCheckedChanged="Check_Controls(chkFirst.ID,lblFirstCheck.ID)" />
<asp:Label runat="server"
ID="lblFirstCheck"
Text=""></asp:Label>
</code>
Default.aspx.vb
<code>
Sub Check_Controls(ByVal sender As Object, ByVal e As String)
Dim tmpCheck As CheckBox = Page.FindControl(sender)
Dim tmpLabel As Label = Page.FindControl(e)
If tmpCheck.Checked = True Then
tmpLabel.Text = "Checked!"
Else
tmpLabel.Text = "Not checked :("
End If
End Sub
</code> |
|
If i call a separate sub and use it declare and pass the label.id and checkbox.id into Check_Controls then it works like a champ.
If i use the code as posted above, it generates the error: "'AddressOf' operand must be the name of a method (without parentheses)" for the line with OnCheckedChanged.
I made buttons that pass in this manner without any trouble using 'commandargument' but checkboxes don't seem to have an equivalent setup.
I've googled and googled and googled but haven't found any way to do this. The only thing close is a brief mention by someone that they used the "cssClass" attribute as a workaround but they didn't expand on exactly 'how' they did it.
Any help would be appreciated. ^_^
modified on Friday, April 25, 2008 12:20 PM
|
|
|
|
|
What are you exactly trying to do??
Am i missing something??
Sub Check_Controls(ByVal sender As Object, ByVal e As String)
If chkFirst.Checked = True Then
lblFirstCheck.Text = "Checked!"
Else
lblFirstCheck.Text = "Not checked "
End If
End Sub
the_0live wrote: i pretty much have the basics down
If this was your question
Im sorry to tell you, But you dont have any basics down
Alexei Rodriguez
|
|
|
|
|
like i said, i'm trying to pass a value similar to the 'commandargument' property of a button. for instance instead of just passing checked/not checked i'd like to be able to pass a separate variable/string:
with a button i can do this:
Sub Button_Controls(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.CommandEventArgs)
Dim tmpLabel As Label = Page.FindControl(e.CommandArgument)
If tmpLabel.Visible = True Then
tmpLabel.Visible = False
tmpLabel.Text = ""
Else
tmpLabel.Visible = True
tmpLabel.Text = "Now I have text!"
End If
End Sub
in a checkbox, i can only seem to pass whether or not the box was checked. not an actual value.
my goal is to have (like the working button example above) a single sub that can handle multiple checkboxes and their corresponding labels.
|
|
|
|
|
anyone? anything? is there maybe another site/forum i could take this question to?
|
|
|
|
|
Hai all,
i had some code which is hard coded...
like
<private function="" getsmsuriforclickatellgateway()="" as="" string<br="" mode="hold"> Const strUserID As String = "zoo"
Const strpwd As String = "test"
Const strapiID As String = "301"
Const strFrom As String = "zoo"
Const strurl As String = "http://api.xyz.com/http/sen?"
Dim strUseURL As String = ""
Dim strSMSURL As String = "" >
my requirement is that hard coded data will be taken in xml file and that xml data will be swnded to another file (like sms or mail)
Thanks
Subbu.
|
|
|
|
|
check this out:
http://www.exforsys.com/tutorials/vb.net-2005/using-xml-data.html
|
|
|
|
|
Hi Please Help me,
I am generating one excel file in button click …it’s working in local system…but when I deploy in server it shows following error…..
My system contain office 2003 .but server contain 2007 …I think it is not an issue ….....
Exception from HRESULT: 0x800A03EC
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Runtime.InteropServices.COMException: Exception from HRESULT: 0x800A03EC
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[COMException (0x800a03ec): Exception from HRESULT: 0x800A03EC]
Excel.WorkbookClass.SaveAs(Object Filename, Object FileFormat, Object Password, Object WriteResPassword, Object ReadOnlyRecommended, Object CreateBackup, XlSaveAsAccessMode AccessMode, Object ConflictResolution, Object AddToMru, Object TextCodepage, Object TextVisualLayout, Object Local) +0
CustomizeExcel.excel_view(DataSet ReportDetails, String Heading, String Filepath) +2245
Forms_frmStoreVendorEnquiry.ExportExecl() +124
Forms_frmStoreVendorEnquiry.btnMail_Click(Object sender, ImageClickEventArgs e) +450
System.Web.UI.WebControls.ImageButton.OnClick(ImageClickEventArgs e) +86
System.Web.UI.WebControls.ImageButton.RaisePostBackEvent(String eventArgument) +115
System.Web.UI.WebControls.ImageButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1746
I am using Bellow Code for generate Excel File
public static string excel_view(DataSet ReportDetails, string Heading, string Filepath)
{
Application excelApp = new ApplicationClass();
excelApp.Visible = false;
string workbookPath = Filepath;
Excel.Workbook excelWorkbook = excelApp.Workbooks.Open(workbookPath, 0, true, 5, "", "", true, Excel.XlPlatform.xlWindows, "",
true, false, 0, true, false, false);
Excel.Sheets excelSheets = excelWorkbook.Worksheets;
string currentSheet = "rigvessel";
Excel.Worksheet excelWorksheet = (Excel.Worksheet)excelSheets.get_Item(currentSheet);
//excelWorksheet.SaveAs("D:/APR-14-VSS/OutBound/Test12345.xls", Excel.XlFileFormat.xlExcel4Workbook, Type.Missing, Type.Missing, Type.Missing
// , Type.Missing, Excel.XlSaveAsAccessMode.xlNoChange, Type.Missing, Type.Missing, Type.Missing);
string strRange;
int intAscii = 65;
Range mycell = (Range)excelWorksheet.get_Range("D14", "D14");
mycell.Value2 = Heading;
mycell.Font.Bold = true;
mycell.Font.Size = 12;
for (int xlcol = 0; xlcol < ReportDetails.Tables[0].Columns.Count; xlcol++)
{
strRange = Convert.ToChar(intAscii).ToString();
Range excelCell = (Range)excelWorksheet.get_Range(strRange + 21, strRange + 21);
//excelCell.Font.Bold = true;
excelCell.ColumnWidth = 15;
excelCell.Interior.ColorIndex = 37;
excelCell.Value2 = ReportDetails.Tables[0].Columns[xlcol].ColumnName.ToString();
Range mycell1 = (Range)excelWorksheet.get_Range("D21", "D21");
mycell1.ColumnWidth = 30;
Range EnquiryNo = (Range)excelWorksheet.get_Range("F15", "G15");
Range JobId = (Range)excelWorksheet.get_Range("F16", "F16");
Range date = (Range)excelWorksheet.get_Range("F17", "F17");
Range ClientName = (Range)excelWorksheet.get_Range("A16", "A16");
Range KindAttention = (Range)excelWorksheet.get_Range("A18", "A18");
//EnquiryNo.Value2 = "EnquiryId"+ReportDetails.Tables[1].Columns[xlcol].ColumnName.ToString();
JobId.Value2 = "JOBID :" + ReportDetails.Tables[1].Rows[0]["jobId"];
date.Value2 = "DATE :" + ReportDetails.Tables[1].Rows[0]["DATEOFENQUIRY"];
ClientName.Value2 = ReportDetails.Tables[1].Rows[0]["NAME"];
KindAttention.Value2 = "Kind Attn :" + ReportDetails.Tables[1].Rows[0]["PERSONINCHARGE"];
for (int xlrow = 0; xlrow < ReportDetails.Tables[0].Rows.Count; xlrow++)
{
Range excelCell1 = (Range)excelWorksheet.get_Range(strRange + (xlrow + 21).ToString(), strRange + (xlrow + 21).ToString());
excelCell1.Application.get_Range(strRange + (xlrow + 21).ToString(), strRange + (xlrow + 21).ToString()).HorizontalAlignment = XlHAlign.xlHAlignLeft;
excelCell1.Value2 = ReportDetails.Tables[0].Rows[xlrow][xlcol].ToString();
excelCell1.WrapText = true;
}
intAscii += 1;
}
//excelApp.SaveWorkspace(@"E:\saisuneel.xls");
//excelApp.ActiveWorkbook.Close("",@"E:\saisuneel.xls","");
string savepath;
string timestamp = DateTime.Now.ToString("yyyyMMddhhmmss");
savepath = System.Web.HttpContext.Current.Request.PhysicalApplicationPath;
savepath = savepath + @"OutBound" + @"\" + ReportDetails.Tables[1].Rows[0]["jobId"].ToString() + Heading + timestamp + ".xls";
//excelWorksheet.SaveAs(savepath, Excel.XlFileFormat.xlExcel4Workbook, Type.Missing, Type.Missing, Type.Missing
//, Type.Missing, Excel.XlSaveAsAccessMode.xlNoChange, Type.Missing, Type.Missing, Type.Missing);
excelWorkbook.SaveAs(savepath, Excel.XlFileFormat.xlExcel4Workbook, Type.Missing, Type.Missing, Type.Missing
, Type.Missing, Excel.XlSaveAsAccessMode.xlNoChange, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
Thread.Sleep(1000);
excelWorkbook.Close(false, Type.Missing, Type.Missing);
excelApp.Quit();
excelWorkbook = null;
excelSheets = null;
return @"\" + ReportDetails.Tables[1].Rows[0]["jobId"].ToString() + Heading + timestamp + ".xls";
}
|
|
|
|
|
Hello all,
I want to use this code
protected void Cartgrid_RowUpdating(object sender,GridViewUpdateEventArgs e)<br />
{<br />
TextBox QuantityTextBox = (TextBox)Cartgrid.Rows(e.RowIndex).cells(2).controls(0);<br />
<br />
}
Cartgrid is a shopping cart.
but it has this error :'System.Web.UI.WebControls.GridView.Rows' is a 'property' but is used like a 'method'
now what do i do?
how can use this code without this Error?
Hoda
|
|
|
|
|
Did you mess up ( with [ and its associated closing character?
Vasudevan Deepak Kumar
Personal Homepage Tech Gossips
A pessimist sees only the dark side of the clouds, and mopes; a philosopher sees both sides, and shrugs; an optimist doesn't see the clouds at all - he's walking on them. --Leonard Louis Levinson
|
|
|
|
|
change
(e.RowIndex)
to
[e.RowIndex]
|
|
|
|
|
At first i didnt notice the () instead of the [] until i saw your answers, im used to VB
Besides (e.RowIndex), shouldnt he also change the cells(2) and controls(0)??
Alexei Rodriguez
|
|
|
|
|
Hello...
i am using datalist. i have taken a table in Datalist.and i want to use another datalist in this table. When i use another datalist .then DataBind is not working.
So i can use one Datalist into Another Datalist?
and also I have to Fetch record in Both DataList from different tables.
|
|
|
|
|
|
now, isn't this article providing code to him...? where is the ethical issue gone of spoiling a developer..... ?
ridiculous!
i hate to comment on other's work....and also expects the same....
Ashish Sehajpal
|
|
|
|
|
Yes you can
You can get the data from 2 different tables
I would use a dataset
Bind Table1 to parent datalist
And on ItemDataBound event of parent datalist get the corresponding rows from table2 and bind them to child datalist
This way, you dont have to read from DB once for each row on table1
Alexei Rodriguez
|
|
|
|
|