Unless, I am not debugging this correctly, when I tried debugging, it keeps breaking on Repeater1 but shows boatYrBuilt as the culprit even though it is likely to not be the issue.
In other words, I enter account number, click enter and it loads page 1 which has personal info like name, phone, address, etc.
Then as soon as I click Next (to go to page2 which is Repeater1), it throws the incorrect format string error.
Could it be these?
<ItemTemplate><tr><td><asp:TextBoxID="txtboatregNum"Text='<%# Eval("MarineRegNo") %>'runat="server"placeholder="Enter registration #..."Style="width: 450px;"class="form-control"></asp:TextBox></td><td><asp:TextBoxID="txtPayerret"Text='<%# Eval("TaxPyrRetdVal") %>'runat="server"placeholder="Enter Taxpayer returned value as of Jan. 1..."Style="width: 400px;"class="form-control txtPayerret"></asp:TextBox></td></tr><tr><td><asp:TextBoxID="cgaurdNumber"Text='<%# Eval("VesselRegNo") %>'runat="server"placeholder="Enter Coast Guard #..."Style="width: 450px;"class="form-control"></asp:TextBox></td><td><asp:TextBoxID="cguardreturnedval"Text='<%# Eval("VesselTaxPyrRetdVal") %>'runat="server"placeholder="Enter Taxpayer returned value as of Jan. 1..."Style="width: 400px;"class="form-control txtPayerret"></asp:TextBox></td><td><asp:ButtonID="BtnAdd"Style="width: 150px;"runat="server"Text="Next Boat"OnClick="BtnAdd_Click"CssClass="btnclass"/><asp:ButtonID="btnDelete"Style="width: 120px;"runat="server"Text="Remove a row"OnClick="btnDelete_Click"CommandArgument='<%# Container.ItemIndex %>'CssClass="btnclass"/></td></tr></ItemTemplate>
I know you have been very patient with me and you have given me more than I asked for (Thank you) but can you please look at the below code for me?
The problem I believe, is that when I enter an account number, it is not populating the form.
Could you please see if there is something to change with the code below?
TER PROCEDURE [dbo].[sp_AllRecs]
SET NOCOUNT ON;
SELECT ROW_Number() OVER (ORDER BY(SELECT 0)) RowNumber, mp.[DateSold] as datesold
,mp.[SalePrice] as salePrice
,mp.[Description] as Description
,mp.[BuyerFullName] as buyername
,mp.[BuyerAddress] as buyeraddress
,mp.[BuyerCity] as buyercity
,mp.[BuyerState] as buyerstate
,mp.[BuyerZipCode] as buyerzip
,mp.[mDateSold] as mdatesold
,mp.[mSalePrice] as msalePrice
,mp.[mDescription] as mDescription
,mp.[mBuyerFullName] as mbuyername
,mp.[mBuyerAddress] as mbuyeraddress
,mp.[mBuyerCity] as mbuyercity
,mp.[mBuyerState] as mbuyerstate
,mp.[mBuyerZipCode] as mbuyerzip
,mp.[PreviousOwnerName] as PrevOnwerName
,mp.[PreviousOwnerAddress] as prevAddr
,mp.[PreviousOwnerCity] as prevCity
,mp.[PreviousOwnerState] as PrevState
,mp.[PreviousOwnerZipCode] as prevzip
,mp.[mPreviousOwnerName] as mprevOnwerName
,mp.[mPreviousOwnerAddress] as mprevAddr
,mp.[mPreviousOwnerCity] as mprevCity
,mp.[mPreviousOwnerState] as mPrevState
,mp.[mPreviousOwnerZipCode] as mprevzip
,ms.County As boatcnty
,ms.Registration_No As aRegNo
,ms.Motor_MFG_Make AS aMake
,ms.Boat_MFG_Make as mMake
,ms.Motor_MFG_Model as ModelNoA
,ms.Boat_MFG_Model as ModelNoM
,ms.Boat_Year_Built as boatYrBuilt
,ms.Motor_Year_Built as motorYrBuilt
,ms.[Length] as blength
,ms.HullMaterial as hullmaterial
,ms.HorsePower as mhorsepower
,ISNULL(ms.HorsePowerType,'NA') as rdlmhorsepType
,ms.Boat_DatePurchased as datePurchased
,ms.Motor_DatePurchased as mdatePurchased
,ISNULL(ms.Boat_PurchaseType,'NA') as PurchaseType
,ms.Motor_PurchaseType as rblmPurchasedType
,ms.MotorCost as motorCost
,ms.BoatCost as boatCost
,ms.boatIssues as rblIssues
,ms.motorIssues as mrblIssues
,ms.boatIssuesDetails as functionalIsses
,ms.motorIssuesDetails as mfunctionalIsses
,mf.TypeOfVessel as vesseltypeUse
,mf.VesselName as vesselname
,mf.HorspwrTypOfEngine as vesselhorsepEngine
,mf.CoastGuardNo AS coastGuardNumber
,mf.YearPurchased as VesselYrPurchased
,mf.PurchaseType as PurchasedNew
,mf.AmtOfPurchase as VesselPurchaseAmt
,mf.HomePort as homePort
,mf.WhereDocked as whereDocked
,mf.Boat_Motor_Accsry_Equip as bmequipAccessoryList
,mf.vesselLength as vessellength
,mf.YrVesselBuilt as vesselYrBult
,mf.VHullMaterial as VesselHullMateria
FROM MarineInfo m
INNER JOIN BoatMarincePurchaserInfo mp ON m.pid = mp.pid
INNER JOIN MarineScheduleD ms ON m.pid = ms.pid
INNER JOIN MarineFedVesselInfo mf ON m.pid = mf.pid
WHERE m.pid = @pin
privatevoid getRecs(int pin)
SqlConnection conn = new SqlConnection(connStr);
SqlCommand cmd = new SqlCommand("sp_AllRecs", conn);
cmd.CommandType = CommandType.StoredProcedure;
SqlParameter p1 = new SqlParameter("@pin", pin);
SqlDataAdapter sda = new SqlDataAdapter(cmd);
DataTable dtPrevRecords = new DataTable();
if (dtPrevRecords.Rows.Count >0)
Repeater2.DataSource = dtPrevRecords;
ViewState["CurrentTable"] = dtPrevRecords;
pageLoad() eventif (!Page.IsPostBack)
Thanks for the quote buddy......... i think you miss something, the connection string i declared that was in Appconfig .... '
' and you doesn't even wanted to know where is my connection string for SQL.......?? but you commented on me. good. Please check the code properly.. And another thing please don't give the free Quote without judgement. Thanks
That's a hard-set connection string, not being pulled from AppConfig. The only part being set in appConfig is the machine path for the directory where the files are stored. You can set a connectionString in AppConfig all day and it literally doesn't matter if you don't use it.
Member 12863453 wrote:
OleDbConnection excelConnection = new OleDbConnection(excelConnectionString);
That's a class that uses the OLEDB provider to connect. That's meant for Office products, not SQL Server. It MIGHT work with SQL Server if the Client Tools Connectivity pack is installed on said server instance, but there's literally no point in using it when you have the native driver available (namely, SqlConnection).
"There are three kinds of lies: lies, damned lies and statistics."
- Benjamin Disraeli
Thanks buddy ,
I Solved it..................
I didn't know there is a joke like you exists.....
I don't even change my code for a single word......
Actually you don't even know .... what i was talking about....???
But the best part is you starting to comment on it..... Isn't it a joke.......??????
Is was a windows service which can move file to desire destination and insert data into sql server in my desired table......
So don't comment in a conversion if you are not able to understand it....
Here is the code for you...
Please run it with VS 2015 and then install the service and check it.........
publicpartialclass Service1 : ServiceBase
long delay = 5000;
protectedstring LogPath = ConfigurationManager.AppSettings["LogPath"];
protectedstring MoveFilePathPath = ConfigurationManager.AppSettings["MovePath"];
protectedoverridevoid OnStart(string args)
delay = Int32.Parse(ConfigurationManager.AppSettings["IntervalInSeconds"]) * 1000;
WriteLog("IntervalInSeconds key/value incorrect.");
if (delay <5000)
WriteLog("Sleep time too short: Changed to default(5 secs).");
delay = 5000;
Timer timer1 = new Timer();
timer1.Elapsed += new ElapsedEventHandler(OnElapsedTime);
timer1.Interval = delay;
timer1.Enabled = true;
privatevoid OnElapsedTime(object source, ElapsedEventArgs e)
string sourcepath = ConfigurationManager.AppSettings["sourcepath"];
WriteLog("Set source path");
string sourcefiles = Directory.GetFiles(sourcepath);
WriteLog("Get soutce path file");
foreach (string childfile in sourcefiles)
WriteLog("Start to find file from loop");
string sourceFileName = new FileInfo(childfile).Name;
string destinationPath = ConfigurationManager.AppSettings["destinationPath"];
string destinationFileName = sourceFileName;
string sourceFile = Path.Combine(sourcepath, sourceFileName);
WriteLog("Get file from source to destination");
string destinationFile = Path.Combine(destinationPath, destinationFileName);
WriteLog("Ready to copy");
File.Copy(sourceFile, destinationFile, true);
string excelPath = ConfigurationManager.AppSettings["ExcelPath"];
DirectoryInfo d = new DirectoryInfo(excelPath);
FileInfo Files = d.GetFiles("*.xlsx");
string str = "";
WriteLog("ready to enter into loop");
foreach (FileInfo file in Files)
str = file.Name;
string sourceFilePath = ConfigurationManager.AppSettings["SourceFilePath"];
string SourceFileName = Path.Combine(sourceFilePath, str);
string destinationFilePath = ConfigurationManager.AppSettings["MovePath"];
string destinationFileName = destinationFilePath + str;
WriteLog("get file :" + str);
String strConnection = ConfigurationManager.AppSettings["constr"];
WriteLog("declare database connection");
string path = excelPath + str;
string excelConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path + ";Extended Properties=Excel 12.0;Persist Security Info=False";
WriteLog("declare excel oledb connection");
OleDbConnection excelConnection = new OleDbConnection(excelConnectionString);
OleDbCommand cmd = new OleDbCommand("Select [ID],[Name] from [Sheet1$]", excelConnection);
dReader = cmd.ExecuteReader();
SqlBulkCopy sqlBulk = new SqlBulkCopy(strConnection);
sqlBulk.DestinationTableName = "shrabon";
WriteLog("ready to insert into database");
WriteLog("File moved to bak folder");
protectedvoid WriteLog(string Msg)
FileStream fs = new FileStream(LogPath + "\\" + System.DateTime.Today.ToString("yyyyMMdd") + ".log", FileMode.OpenOrCreate, FileAccess.Write);
StreamWriter sw = new StreamWriter(fs);
sw.WriteLine(System.DateTime.Now.ToString() + ": " + Msg);
Sorry i think i failed to present you the issue..... actually it stuck in there and don't forward to next statement. and go back to the previous method "Upload". So that i told the loop thing. actually there was no loop in that statement. but during this process the service not stopped even once but it continuously repeat the statements