This is my Technical area of troubleshooting and learning new Programming skills and many more. Here you will find answers for many new technologies like asp.net 2.0/3.5,4.0 C# access, mysql, Amazon Webservice ,Sql-server, JD Edwards, SAS, Salesforce, APIs, MVC and many more. please visit & discuss.
Friday, January 28, 2011
Dynamic Sql-srever - table column header name
declare @colnm varchar(20)
declare @strsql varchar(2000)
set @colnm='1625195'
--set @strsql='select ['+ @colnm + '] from ia_book1 where ['+ @colnm + '] =''1625195'+''+char(39)
set @strsql='select * from ia_book1 where ['+ @colnm + '] ='+char(39)+@colnm +char(39)
Print @strsql
exec(@strsql)
JD Edwards IB Batch Error: The AA ledger type for 1/22/2011 , document xxxxxx is out of balance by xxxx.xx .
Thursday, January 27, 2011
docs
1. vdcsvfl structure should be as same as table name: Reporting (Done).
2. All final data must be inserted into table name: Reporting.
(Done with new date field)
3. All SQL Statement must be converted into Stored Procedure.
(Done)
Web:
1. Add CheckAll Checkbox so once it is checked, all checkboxes will be
checked.(Done)
2. Add AllowSorted in Gridview equal to true.(Done)
3. The Submit button <<next the browse>> should not be shown until
the browse textbox has value. (Not yet)
5. Delete proddta.aspx. We don't need it. Reporting.aspx will show all
information from Reporting table.
(done) in case you want to see Data for reporting table I am not
deleting this program. If you want to use you can use.
6. Validate the value when it is updated. At least check if it is empty.(Done)
Checking if file is .csv or not. If no file selected won't do anything.
7. <<A favor>> Please add textbox and it is a date field. I need this
date field saved into Reporting Table.
Done.
A date field called ReportingDate will be created in the Reporting table.
DateTime formate C#,vb asp.net 4.0
DateTime.Now; | 1/27/2011 11:22:45 AM |
DateTime.Now.ToString(); | 1/27/2011 11:22:45 AM |
DateTime.Now.ToShortTimeString() | 11:22 AM |
DateTime.Now.ToShortDateString() | 1/27/2011 |
DateTime.Now.ToLongTimeString() | 11:22:45 AM |
DateTime.Now.ToLongDateString() | Thursday, January 27, 2011 |
DateTime.Now.ToString("d") | | 1/27/2011 |
DateTime.Now.ToString("D") | | Thursday, January 27, 2011 |
DateTime.Now.ToString("f") | | Thursday, January 27, 2011 11:22 AM |
DateTime.Now.ToString("F") | | Thursday, January 27, 2011 11:22:45 AM |
DateTime.Now.ToString("g") | | 1/27/2011 11:22 AM |
DateTime.Now.ToString("G") | | 1/27/2011 11:22:45 AM |
DateTime.Now.ToString("m") | | January 27 |
DateTime.Now.ToString("r") | | Thu, 27 Jan 2011 11:22:45 GMT |
DateTime.Now.ToString("s") | | 2011-01-27T11:22:45 |
DateTime.Now.ToString("t") | | 11:22 AM |
DateTime.Now.ToString("T") | | 11:22:45 AM |
DateTime.Now.ToString("u") | | 2011-01-27 11:22:45Z |
DateTime.Now.ToString("U") | | Thursday, January 27, 2011 5:22:45 PM |
DateTime.Now.ToString("y") | | January, 2011 |
DateTime.Now.ToString("dddd, MMMM dd yyyy") | | Thursday, January 27 2011 |
DateTime.Now.ToString("ddd, MMM d "'"yy") | | Thu, Jan 27 '11 |
DateTime.Now.ToString("dddd, MMMM dd") | | Thursday, January 27 |
DateTime.Now.ToString("M/yy") | | 1/11 |
DateTime.Now.ToString("dd-MM-yy") | | 27-01-11 |
csv file upload csv ,net c#
{
string filePath = FileUpLoad1.PostedFile.FileName;
string filenameStor = FileUpLoad1.FileName;
string filenameType = Path.GetExtension(FileUpLoad1.PostedFile.FileName);
if (filenameType.ToString().Trim().ToLower() == ".csv")
{
FileUpLoad1.SaveAs(@"c:\\sites\\" + "Book1.csv");
lblStatus.Text = "File Uploaded : " + FileUpLoad1.PostedFile.FileName;
insFileName();
SqlDataSource1.SelectCommand = "SELECT * FROM vdcsvfl";
gvid.Visible = true;
Button1.Visible = true;
}
else
{
lblStatus.Text =
"Invalid File Type...";}
}
else{
lblStatus.Text =
"No File Uploaded.";gvid.Visible =
true;Button1.Visible =
true;}
}
void insFileName(){
SqlConnection myConnection = new SqlConnection(ConnectionString); string strSQL;strSQL =
"insbulkcsvP"; SqlCommand cmd = new SqlCommand(strSQL, myConnection);cmd.CommandType =
CommandType.StoredProcedure;myConnection.Open();
cmd.ExecuteNonQuery();
myConnection.Close();
lblStatus.Text =
"Added..";ALTER
proc [dbo].[insbulkcsvP] asdelete
from dbo.vdcsvflAlter
Table vdcsvfl Drop Column id--ALTER TABLE a DROP COLUMN y
BULK
INSERT dbo.vdcsvflFROM
'c:\sites\Book1.csv'WITH
(
FIELDTERMINATOR
= ',',ROWTERMINATOR
= '\n')
delete
from dbo.vdcsvfl where video_id='video_id'Alter
Table vdcsvfl Add id int identity(1,1) --primary keyWednesday, January 26, 2011
Find & Replace Sql-server update
SET adds = replace([city], 'Bihar', 'Jharkhand')
WHERE adds LIKE 'Bihar%';
Tuesday, January 25, 2011
Godaddy Hosting Account's Absolute Path
To Find Your Absolute Hosting Path
- Log in to your Account Manager.
- From the Products section, click Web Hosting.
- Next to the hosting account you want to use, click Launch.
Alter table add identity column
'1,2,3,4' sql-server - Split Function in Sql Server to break Comma-Separated Strings into Table
returns @temptable TABLE (items varchar(8000))
as
begin
declare @idx int
declare @slice varchar(8000)
select @idx = 1
if len(@String)<1 or @String is null return
while @idx!= 0
begin
set @idx = charindex(@Delimiter,@String)
if @idx!=0
set @slice = left(@String,@idx - 1)
else
set @slice = @String
if(len(@slice)>0)
insert into @temptable(Items) values(@slice)
set @String = right(@String,len(@String) - @idx)
if len(@String) = 0 break
end
return
end
select top 10 * from dbo.split('Chennai,Bangalore,Mumbai',',')
http://www.logiclabz.com/sql-server/split-function-in-sql-server-to-break-comma-separated-strings-into-table.aspx
Thursday, January 20, 2011
upload excel file and upload to sql-server c# asp.net 4.0
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
<!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 runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div> <asp:FileUpLoad id="FileUpLoad1" runat="server" /><asp:Button id="UploadBtn" Text="Upload File" OnClick="UploadBtn_Click" runat="server" Width="105px" CssClass="but" />
<br />
<br />
<br />
<br />
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</div>
</form>
</body>
</html>
code behind
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.OleDb;
using System.Data.Common;
using System.Data.SqlClient;
using System.Configuration;
public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void UploadBtn_Click(object sender, EventArgs e)
{
if (FileUpLoad1.HasFile)
{
string filePath = FileUpLoad1.PostedFile.FileName;
string filenameStor = FileUpLoad1.FileName;
FileUpLoad1.SaveAs(@"c:\\" + "Book1.xls");
Label1.Text = "File Uploaded : " + FileUpLoad1.PostedFile.FileName;
datatosql();
}
else
{
Label1.Text = "No File Uploaded.";
}
}
void datatosql()
{
string strConn = @"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=c:\Book1.xls;Extended Properties=""Excel 8.0;HDR=NO;IMEX=1""";
using (OleDbConnection connection = new OleDbConnection(strConn))
{
OleDbCommand command = new OleDbCommand("Select * FROM [Sheet1$]", connection);
connection.Open();
using (DbDataReader dr = command.ExecuteReader())
{
using (SqlBulkCopy bulkCopy = new SqlBulkCopy(ConnectionString))
{
bulkCopy.DestinationTableName = "testexceldata";
bulkCopy.WriteToServer(dr);
}
}
}
}
private string ConnectionString
{
get
{
string connectionString = ConfigurationManager.ConnectionStrings["smdbConnectionString"].ConnectionString;
return connectionString;
}
}
}
Display Excel data in Gridview asp.net c#
myCommand.Fill(myDataSet,
"ExcelInfo");GridView1.DataSource = myDataSet.Tables[
"ExcelInfo"].DefaultView;GridView1.DataBind();
The 'Microsoft.Jet. OLEDB.4.0' provider is not registered on the local machine.- Error 64 bit 4.0
You will have to run asp.net in 32 bit environment
Run following command
cscript c:\inetpub\adminscripts\adsutil.vbs SET W3SVC/AppPools/Enable32bitAppOnWin64 0
c:\windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -i
Word or PDF into Database sql-server c#
{
SqlCommand command = new SqlCommand( "INSERT INTO Image (img_name,img_data,img_contenttype) VALUES ( @img_name, @img_data,@img_contenttype )", connection );
param0.Value = imgName;
command.Parameters.Add( param0 );
param1.Value = imgbin;
command.Parameters.Add( param1 );
param2.Value = imgcontenttype;
command.Parameters.Add( param2 );
int noRowsAffected = command.ExecuteNonQuery();
connection.Close();
Wednesday, January 19, 2011
Read & create tabs excel file C#
http://support.microsoft.com/kb/306023
Monday, January 17, 2011
HyperLinkField which are not part of your Gridview DataSource
To change the path for linked tables in access
- Open the database that contains links to tables.
- On the Tools menu, point to Database Utilities, and then click Linked Table Manager.
- Select the Always prompt for new location check box.
- Select the check box for the tables whose links you want to change, and then click OK.
- In the Select New Location of <table name> dialog box, specify the new location, click Open, and then click OK.
Sunday, January 16, 2011
WPF Two-way Databinding in ASP.NET
Friday, January 14, 2011
Using Razor Pages with WebForms Master Pages
On a secondary project that I work on within Microsoft, we were given the ability to rewrite the entire UI of the application in ASP.NET MVC. At that time, the first beta of MVC3 was rolling out and we decided to take our first plunge and use the Razor view engine. Unfortunately, the common UI layout that is shared across multiple properties that we had to use was WebForms based. Our attempts to convince the developers of the common UI components to support more of a modularized infrastructure failed for any foreseeable future, so we were left with the conundrum of figuring out an intermediary solution.
http://www.eworldui.net/blog/post/2011/01/07/Using-Razor-Pages-with-WebForms-Master-Pages.aspx
Building an HTML5 App with ASP.NET
The application takes advantage of HTML5 local storage to store all of the reference entries on the local browser. IE 8, Chrome 8, Firefox 3.6, and Safari 5 all support local storage.
When you open the application for the first time, all of the reference entries are transferred to the browser. The data is stored persistently. Even if you shutdown your computer and return to the application many days later, the data does not need to be transferred again.
http://stephenwalther.com/blog/archive/2011/01/11/building-an-html5-app-with-asp-net.aspx
Thursday, January 13, 2011
sql-server 2008 express how to save Import and Export Wizard
Wednesday, January 12, 2011
The settings saved on this computer do not match the requirements of the wireless network.
Monday, January 10, 2011
Cross tab query in sql-server sample
declare
@drweek as varchar(15)declare
@fdate1 as varchar(15)declare
@fdate2 as varchar(15)declare
@fdate3 as varchar(15)declare
@fdate4 as varchar(15)declare
@fdate5 as varchar(15)declare
@fdate6 as varchar(15)declare
@fdate7 as varchar(15)declare
@fdate8 as varchar(15)declare
@fdate9 as varchar(15)declare
@SQL varchar (max)set
@drdate='1/3/2010'select
@drweek=drweek from dbo.DateRef where drdate=@drdateset
@fdate1=convert(varchar(10), cast(@drweek as datetime),101)set
@fdate2=convert(varchar(10),dateadd(day,1,@fdate1),101)set
@fdate3=convert(varchar(10),dateadd(day,1,@fdate2),101)set
@fdate4=convert(varchar(10),dateadd(day,1,@fdate3),101)set
@fdate5=convert(varchar(10),dateadd(day,1,@fdate4),101)set
@fdate6=convert(varchar(10),dateadd(day,1,@fdate5),101)set
@fdate7=convert(varchar(10),dateadd(day,1,@fdate6),101)set
@fdate8=convert(varchar(10),dateadd(day,1,@fdate7),101)set
@fdate9=convert(varchar(10),dateadd(day,1,@fdate8),101)select
distinct m.FICLBNO,m.FIUPC,m.prscitemno,m.prsamsitemno,m.OwnerName,m.HubName,isnull
(m1.FIQTY,0) Q1 ,isnull(m1.FICOST,0) C1,isnull(m1.FISALES,0) T1,isnull
(m2.FIQTY,0) Q2,isnull(m2.FICOST,0) C2,isnull(m2.FISALES,0)T2,isnull
(m3.FIQTY,0) Q3,isnull(m3.FICOST,0) C3,isnull(m3.FISALES,0)T3,isnull
(m4.FIQTY,0) Q4,isnull(m4.FICOST,0) C4,isnull(m4.FISALES,0)T4,isnull
(m5.FIQTY,0) Q5,isnull(m5.FICOST,0) C5,isnull(m5.FISALES,0)T5,isnull
(m6.FIQTY,0) Q6,isnull(m6.FICOST,0) C6,isnull(m6.FISALES,0)T6,isnull
(m7.FIQTY,0) Q7,isnull(m7.FICOST,0) C7,isnull(m7.FISALES,0)T7,isnull
(m8.FIQTY,0) Q8,isnull(m8.FICOST,0) C8,isnull(m8.FISALES,0)T8,isnull
(m9.FIQTY,0) Q9,isnull(m9.FICOST,0) C9,isnull(m9.FISALES,0)T9from
smrsalesrep_m mleft
outer join smrsalesrep m1 on m.FICLBNO=m1.FICLBNO and m.FIUPC=m1.FIUPC and m.prscitemno=m1.prscitemnoand
m.prsamsitemno=m1.prsamsitemno and m.OwnerName=m1.OwnerName and m.HubName=m1.HubName and m1.FISALDAT=@fdate1left
outer join smrsalesrep m2 on m.FICLBNO=m2.FICLBNO and m.FIUPC=m2.FIUPC and m.prscitemno=m2.prscitemnoand
m.prsamsitemno=m2.prsamsitemno and m.OwnerName=m2.OwnerName and m.HubName=m2.HubName and m2.FISALDAT=@fdate2left
outer join smrsalesrep m3 on m.FICLBNO=m3.FICLBNO and m.FIUPC=m3.FIUPC and m.prscitemno=m3.prscitemnoand
m.prsamsitemno=m3.prsamsitemno and m.OwnerName=m3.OwnerName and m.HubName=m3.HubName and m3.FISALDAT=@fdate3left
outer join smrsalesrep m4 on m.FICLBNO=m4.FICLBNO and m.FIUPC=m4.FIUPC and m.prscitemno=m4.prscitemnoand
m.prsamsitemno=m4.prsamsitemno and m.OwnerName=m4.OwnerName and m.HubName=m4.HubName and m4.FISALDAT=@fdate4left
outer join smrsalesrep m5 on m.FICLBNO=m5.FICLBNO and m.FIUPC=m5.FIUPC and m.prscitemno=m5.prscitemnoand
m.prsamsitemno=m5.prsamsitemno and m.OwnerName=m5.OwnerName and m.HubName=m5.HubName and m5.FISALDAT=@fdate5left
outer join smrsalesrep m6 on m.FICLBNO=m6.FICLBNO and m.FIUPC=m6.FIUPC and m.prscitemno=m6.prscitemnoand
m.prsamsitemno=m6.prsamsitemno and m.OwnerName=m6.OwnerName and m.HubName=m6.HubName and m6.FISALDAT=@fdate6left
outer join smrsalesrep m7 on m.FICLBNO=m7.FICLBNO and m.FIUPC=m7.FIUPC and m.prscitemno=m7.prscitemnoand
m.prsamsitemno=m7.prsamsitemno and m.OwnerName=m7.OwnerName and m.HubName=m7.HubName and m7.FISALDAT=@fdate7left
outer join smrsalesrep m8 on m.FICLBNO=m8.FICLBNO and m.FIUPC=m8.FIUPC and m.prscitemno=m8.prscitemnoand
m.prsamsitemno=m8.prsamsitemno and m.OwnerName=m8.OwnerName and m.HubName=m8.HubName and m8.FISALDAT=@fdate8left
outer join smrsalesrep m9 on m.FICLBNO=m9.FICLBNO and m.FIUPC=m9.FIUPC and m.prscitemno=m9.prscitemnoand
m.prsamsitemno=m9.prsamsitemno and m.OwnerName=m9.OwnerName and m.HubName=m9.HubName and m9.FISALDAT=@fdate9