|
i got a few pdfs i read thru that i got from my friend studying c# ,
|
|
|
|
|
There's a really good free PDF-book on programming in C#, which you can download here: http://www.introprogramming.info/[^]
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
|
|
|
|
|
thanks man
|
|
|
|
|
You should get a decent idea of what needs to be done, here[^]. Look at the first answer to get an idea on how to do this without leaving your code vulnerable to SQL Injection Attacks.
|
|
|
|
|
Hi,
I want to fetch data from SQL database, and display the same on my HTML page in table format using Angular JS.
I am able to get the data in the scope variable, but it is not getting displayed in the HTML page.
Please check the code that I have written below, and help me fixing the issue.
Thanks in advance.
HTML code:
<!DOCTYPE html>
<html>
<head>
<title>:: View Logs ::</title>
<script src="Scripts/angular.js"></script>
<script src="Scripts/angular.min.js"></script>
<!--<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>-->
<script src="Scripts/logsController.js"></script>
<script src="Scripts/jquery-2.1.1.js"></script>
<script src="Scripts/jquery-2.1.1.min.js"></script>
<!--<script>
ViewLogsApp = angular.module('ViewLogsApp', []);
ViewLogsApp.controller('ViewLogsController', function ($scope, $http) {
$http.get('data.json').success(function (response) {
$scope.myData = response;
});
});
</script>-->
</head>
<body>
<div ng-app="ViewLogsApp">
<div ng-controller="ViewLogsController">
<table class="table table-striped">
<tr>
<th>Log ID</th>
<th>User Type</th>
<th>User Name</th>
<th>Email ID</th>
<th>Action Type</th>
<th>Section Name</th>
<th>Section Details</th>
<th>DateTime</th>
<th>User IP</th>
</tr>
<tr ng-repeat="item in logslist">
<td>{{item.LogID}}</td>
<td>{{item.UserType}}</td>
<td>{{item.UserName}}</td>
<td>{{item.EmailID}}</td>
<td>{{item.ActionType}}</td>
<td>{{item.SectionName}}</td>
<td>{{item.SectionDetails}}</td>
<td>{{item.DateTime}}</td>
<td>{{item.UserIP}}</td>
</tr>
</table>
</div>
</div>
</body>
</html>
logsController.js code:
angular.module('ViewLogsApp', [])
.controller('ViewLogsController', [
'$scope', function ($scope) {
$scope.logslist = [];
$scope.load;
$scope.load = function () {
$.ajax({
type: 'GET',
contentType: 'application/json; charset=utf-8',
url: 'UserActivityLogs.aspx/getList',
success: function (data) {
$scope.logslist = data
$scope.$apply();
}
});
}
$scope.load();
}
]);
WebMethod code:
[System.Web.Services.WebMethod]
[ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
public static List<UserActivityLogsList> getList()
{
SqlConnection con = new SqlConnection();
con.ConnectionString = _connstr;
con.Open();
var logs = new List<UserActivityLogsList>();
string get = "select * from UserActivityLogs";
SqlCommand cmd = new SqlCommand(get, con);
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
UserActivityLogsList e = new UserActivityLogsList();
e.LogID = Convert.ToInt32(dr[0]);
e.UserType = Convert.ToString(dr[1]);
e.UserName = Convert.ToString(dr[2]);
e.EmailID = Convert.ToString(dr[3]);
e.ActionType = Convert.ToString(dr[4]);
e.SectionName = Convert.ToString(dr[4]);
e.SectionDetails = Convert.ToString(dr[4]);
e.DateTime = Convert.ToString(dr[4]);
e.UserIP = Convert.ToString(dr[4]);
logs.Add(e);
}
con.Close();
return logs;
}
Clouds come floating into my life, no longer to carry rain or usher storm, but to add color to my sunset sky. ~Rabindranath Tagore
|
|
|
|
|
This is not a C# issue. Please use the ASP.NET or Javascript forum, as appropriate.
|
|
|
|
|
So I'm using this command to open a picture in C sharp
Process.Start(@"C:\MyPicture.jpg");
Is there anyway I can open the latest picture in the folder?
|
|
|
|
|
Yes. You could iterate over all the picture files in the directory, looking at the file attributes for the files. That should help you find the latest.
|
|
|
|
|
var directory = new DirectoryInfo(@"C:\");
var latest = (from f in directory.EnumerateFiles("*.jpg")
orderby f.CreationTime
select f.FullName).LastOrDefault();
Console.WriteLine(latest);
Returns null in case there are no jpg files found.
|
|
|
|
|
I am trying to complete a standalone *.exe file that will simply allow read and write FirstSlideNumber property in a PowerPower 2013 pptx file, without opening PowerPoint. (VS 2015).
My application can find the file name etc. but as I am new to C# after returning to programming after 10 years, I need a code fragment example in C#
https://msdn.microsoft.com/EN-US/library/office/ff744279.aspx is VBA is no help.
This is my code fragment:
using System;
using System.IO;
using System.Windows.Forms;
using DocumentFormat.OpenXml;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Presentation;
using Microsoft.Office.Interop.PowerPoint;
using Powerpoint = Microsoft.Office.Interop.PowerPoint;
…
//file Open file
using (PresentationDocument mypptx = PresentationDocument.Open(myFileName, true))
{
Int iFirstSlideNumber = PageStepup?? //PageStepup. Only allows “Equals” or “ReferenceEquals”
}
|
|
|
|
|
|
Of which type is "PageStepup"? Where is it declared?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Error : Must declare the scalar variable "@id".
|
|
|
|
|
Member 11864285 wrote: Must declare the scalar variable "@id".
Most likely because you did not declare the variable @id. But that is just a guess since you decided not to share the code that is causing the error.
You can lead a developer to CodeProject, but you can't make them think.
The Theory of Gravity was invented for the sole purpose of distracting you from investigating the scientific fact that the Earth sucks.
|
|
|
|
|
Your SQL-statement contains a parameter named @id which you didn't supply to the command object. Most probably.
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
|
|
|
|
|
Hi guys,
I want when i have a radio button checked by pressing a button the desired folder with all files in it to be in desktop and replacing anything.
I have this :
public partial class Form1 : Form
{
string desktop = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
and then :
private void button1_Click(object sender, EventArgs e)
{
foreach (string file in Directory.GetFiles(SourceOneToCopyBox.Text))
{
File.Copy(file, Path.Combine(OutputDirectory1.Text, Path.GetFileName(file)), true);
if (YesRadioButton.Checked == true)
{
File.Copy(file, Path.Combine(desktop, Path.GetFileName(file)), true);
}
}
}
Thank you in advance.While the code works for every directory everywhere I can't do anything with the directory I want in desktop.
|
|
|
|
|
octapuslabs wrote: I can't do anything with the directory I want in desktop. I am afraid that is not clear. Please explain exactly what problem you see at this point.
|
|
|
|
|
Let's say I have a directory c:\test with some files in it.I want this directory to be copied in desktop with every file in it.If it exists I want to replace it with the new files .I m making a program so I can have backup of my projects easily and not copying pasting with windows clicks all the time .
This is the whole code which creates a folder in desktop Downloads\Downloads and also some files are copies to desktop\Downloads and some others to desktop\Downloads\Downloads.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
namespace EasyCopyFiles
{
public partial class Form1 : Form
{
string desktop = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
foreach (string file in Directory.GetFiles(SourceOneToCopyBox.Text))
{
File.Copy(file, Path.Combine(OutputDirectory1.Text, Path.GetFileName(file)), true);
if (YesRadioButton.Checked == true)
{
desktop += "\\Downloads";
if (!System.IO.Directory.Exists(desktop))
{
DirectoryInfo directory = Directory.CreateDirectory(desktop);
}
File.Copy(file, Path.Combine(desktop, Path.GetFileName(file)), true);
}
}
}
}
}
Thank you again I m so close to it.Thank you a lot.
|
|
|
|
|
Yes, but what is the problem?
|
|
|
|
|
The problem is that either I can create a new empty folder or if the folder already exists it replaces the files .If the folder doesn't exist I get an error a bug or something which crashes.
|
|
|
|
|
octapuslabs wrote: an error a bug or something which crashes. Well, since we cannot see your screen, we cannot guess which, or what any of them might say. Please provide all the information relating to your problem, including the full details of the error, and the point in your code where it occurs.
|
|
|
|
|
System.IO.DirectoryNotFoundException
{"Could not find a part of the path 'd:\\test\\130123094607-kevin-durant-dunk-lamar-odom-012313.1200x672.jpg'."}
This happens when we have for example to copy c:\test to d:\test and the d:\ doesn't have the folder.If I create the folder manually the error disappears but the thing is I want the folder to be created if it doesn't exist and if it does exist to overwrite every file in it.
Thank you again for your time.
|
|
|
|
|
Then you need first to test if the directory exists, and if not then create it. Similarly when creating files, if they exist in the folder you need to ensure you use a create option that will force it to a new file.
|
|
|
|
|
Yup I thought of that creating first the directory and then copying files but the thing I can t do both.I m having some problem probably in code which I hope I ll find it slowly.The problem is that I can t copy the files when creating the new folder only if it s already there.Thank you again sir.
|
|
|
|
|
It's a two step process. Check to see if the directory exists that you want to copy into and then do the copy. That's what you have to do if you want to stay in the .NET world (of course, you could always spin up a Process and run an xcopy to do the requisite copy).
|
|
|
|