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
//I query the db in pageload() event://We query the DB only once in the Page Load
con = new SqlConnection(ConfigurationManager.ConnectionStrings["ppmtest"].ToString());
string sSQL = "Select sID,sName from states ORDER By sName ASC";
SqlCommand cmd3 = new SqlCommand(sSQL, con);
cstable = new DataTable();
//Then I call it in ItemDataBound...) eventprotectedvoid repeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
var ddlPState = (DropDownList)e.Item.FindControl("ddlPrevState");
ddlPState.DataSource = cstable;
ddlPState.DataTextField = "sName";
ddlPState.DataValueField = "sID";
If I am deploying my site on domain directly all static files are getting loaded and my website is running fine but as I am deploying my website in sub domain, none of the static file(css, fonts, js) is getting loaded.
googled first but do not find any suitable one. so looking for a details article on repository and data access code in dotnet core unit testing
where we will not use any 3rd part library like mock or effort rather use anything built-in.
anything exist such like ?
can we unit test repository and data access code with intellitrace ? share idea. thanks
First of all I'd ask why you don't want to use a mocking framework, it'll make your life a lot easier. However if you don't want to use one then you can use a technique called self-shunting. That is where the test class itself acts as the mocked object and you can write any code you want in your "mocked" methods.
In this brief example I have a ProductService class that uses an IProductRepository to access the products. There's only a simply Get method but it gives you the rough idea. So in my unit test I make the test class implement IProductRepository and I mock the Get method in the test class itself.
I just started to be assigned a work station that was low on memory so I accidently removed the wrong version of the .net framework. To correct the problem, I downloaded .net framework 4.0 since that is what the application uses. This web form application uses vb.net 2010 visual studio ide.
I problem is I probably downloaded the wrong version. The application probably was using a version number 4.3 I am guessing.
Thus I am trying to determine what I need to do to solve the problem.
Here is where the steps of where the problem lies:
'retarget the project to .net framework 4.0. After the project opens, you can retarget the
1. When I try to debug the application, I get the following error message:
”Retarget the project to .net framework 4.0.
Once I see the above message, I just click the OK button. I do not know where to point the application.
2. After that point I get lots of messages that look like the following:
AttendanceLetters\App_Code\mylistbox.vb(1): Build (web): Reference assemblies for target .NET Framework version not found; please ensure they are installed, or select a valid target version.
Thus to solve the problem can you tell me the following:
1. Can you tell me and/or point to a url (link) that will solve the problem tell me how and/or how to point the application to the correct target link?
2. If that is not possible, do I need to download some version of the .net framework that the application is expecting to see? If so, how can I tell what version the application is looking for?
3. If the above solutions do not work. should I uninstall the visual studio 2010 that is on this workstation and reinstall a new version so that the application can find the correct version of the .net framework?
4. If you have a different solution would you tell me what I should do to solve the problem?
Not sure if this is the correct forum to ask this, so if not, please let me know and I will have it changed.
I have created an API for my website that Godaddy hosts on a dedicated server. I have Wordpress installed and it's on a Linux server. I created the API in Visual Studio 2015 Community and ran tests on my local PC and it works as expected. Now, I need to put it online so I can test. I am planning on having it in my WPF desktop program that when the user clicks a button it will call the API and return the result. This API will check a database to see if the license code is there and if not already used. Currently, I have static code that will return a value and not connected to the database yet.
My question: Where on my website do I put files and what files go on the website? Also, how do I find out what the actual URL will be for my button click to call the API?
When you are building a list its items have two parts - text and value, text for display and value to select.
If you are building your list from database you have to decide how values are build, you can use the text as value too in which case text must be unique. If you want to use a text-value pair, you must ensure value is not null (which means that in this case the database must have proper values) - there is no other way, so you must choose...
If you can not change the way the data is, you must filter out those have no value or create a fallback, which uses the text in case value is null..
Skipper: We'll fix it. Alex: Fix it? How you gonna fix this? Skipper: Grit, spit and a whole lotta duct tape.
Let me try to explain this one more time, hopefully better.
We have a lookup table with a list of account numbers.
For a user to fill his/her account information, s/he must first select an account from the look up table.
When that account number is entered, if any records associated with that account exists, then those records populate the Repeater control form.
Users can then either modify any existing record or enter any records that does not exist already exist with that account number.
So, in my situation, if any of those values on the RadioButtonList does not exist, then it throws the error it is throwing now.
This is not a question of inserting null value in RadioButtonList because it is a required field.
It is a question of no value existing at all and user needs to be allowed to choose of the two values but the user cannot get to that point of selecting a value when the error message doesn't let them get there.
I believe this datatable below is the source of the error.
If I can figure out a way to assign it a default value other than empty string, I think it will resolve the issue.
dr = dt.NewRow();
dr["RowNumber"] = 1;
dr["horsepType"] = string.Empty;
dr["rblIssues"] = string.Empty;
dr["vesseltypeUse"] = string.Empty;
dt = (DataTable)ViewState["CurrentTable"];
//Store the DataTable in ViewState for future reference
ViewState["CurrentTable"] = dt;
if (dt.Rows.Count > 0)
//Bind the Repeater with the DataTable
Repeater2.DataSource = dt;
Last Visit: 31-Dec-99 18:00 Last Update: 3-Oct-23 7:45