|
Thanks you sir.. I got the required output
|
|
|
|
|
You're welcome!
Do you understand why?
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Yes sir, It was mistake in xml code only thats why i am not getting the values.i tried using try and catch blocks to check the error.
|
|
|
|
|
If you run your code in the debugger, it will stop on an unhandled exception and show you where (and what) the problem is - and it will let you look at data, change code, run it again, single step your code ... a whole lot more useful than just changing your code to try and find an error!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
ok sir thank you, for your valuable suggestions i will take your suggestions and do further codings.
|
|
|
|
|
I Need To Read SMS Message in C# using AT Command
|
|
|
|
|
If you are waiting for permission, then consider it given: go right ahead.
If you need something else, then please explain what you have tried, what happened when you tried, where you are stuck, and what help you need.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Hi all,
First time poster here and excited to interact with the forum.
I'm using C# and Postgres. I rolled my own security to escape the special chars I was aware off (like single quote), but then was advised that I didn't need to do that - parameterization could do it all for me!
So I deleted (archived) my code and replaced it all with parameterized Npgsqlcommands. Great!
However, a bit of testing shows that it doesn't escape single quotes when using NpgsqlCommand.ExecuteReader().
It seems to work fine when I do NpgsqlCommand.ExecuteNonQuery(). I listed my working code at the bottom of this message in case anyone doing this stumbles across it and finds it useful.
I'm kind of a novice, and would really appreciate someone more experienced to look over my code and help me understand what I'm doing wrong.
Here's my method for SQL queries that return data:
public static bool ExecuteSQLQuery(NpgsqlCommand cmdText, out DataTable dataTable)
{
try
{
string connectionString = ConfigurationManager.AppSettings["connectionString"];
NpgsqlConnection sqlConnection = new NpgsqlConnection(connectionString);
sqlConnection.Open();
cmdText.Connection = sqlConnection;
dataTable = new DataTable();
dataTable.Load(cmdText.ExecuteReader(CommandBehavior.CloseConnection));
sqlConnection.Close();
return true;
}
catch(Exception ex)
{ dataTable = new DataTable(); return false; }
}
Here's my code for calling that code:
DataTable dataTable = new DataTable();
NpgsqlCommand sqlCommand = new NpgsqlCommand("SELECT * FROM users.users WHERE (email ilike @email or username ilike @username)");
sqlCommand.Parameters.AddWithValue("email", NpgsqlTypes.NpgsqlDbType.Varchar, email);
sqlCommand.Parameters.AddWithValue("username", NpgsqlTypes.NpgsqlDbType.Varchar, username);
DatabaseConnectivity.ExecuteSQLQuery(sqlCommand, out dataTable)
If I feed it a single quote character it fails.
Thanks in advance for any help.
PS: Here's my working code for SQL that doesn't return any data:
public static bool ExecuteSQLNonQuery(NpgsqlCommand cmdText)
{
try
{
string connectionString = ConfigurationManager.AppSettings["connectionString"];
NpgsqlConnection sqlConnection = new NpgsqlConnection(connectionString);
sqlConnection.Open();
cmdText.Connection = sqlConnection;
cmdText.ExecuteNonQuery();
sqlConnection.Close();
return true;
}
catch (Exception ex)
{ return false; }
}
|
|
|
|
|
Quote: If I feed it a single quote character it fails. How does it fail?
Is there an error message?
What happens that you don't expect, or doesn't happen that you do?
What - exactly - did you do to test it?
What does the debugger show is happening, and where?
Have you tried using:
sqlCommand.Parameters.AddWithValue("@email", NpgsqlTypes.NpgsqlDbType.Varchar, email);
sqlCommand.Parameters.AddWithValue("@username", NpgsqlTypes.NpgsqlDbType.Varchar, username);
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
|
how I can download usbclass library for win 10?
|
|
|
|
|
|
Just like you download anything else.
|
|
|
|
|
I am facing an issue with SQL Server 2016, we have an application in windows forms to block multiple logins with the same username.
The logic that we implemented to prevent this is: the first time a user logs in to the application a DB connection will be opened and the connection will not be closed until he logs out.
When the second user connects the application using the same username, we will kill the first connection using the KILL command (this logic is implemented inside a stored procedure) after this when the first user does some DB operation the connection StateChange event will be fired and the application will be closed.
This was working perfectly up to ms SQL Server 2012. Recently we have migrated our application to framework 4.7 and SQL Server 2016 after that we are having this issue. In SQL Server 2016 when we kill the first user connection it will disappear from the SYSPROCESSES table but if the user performs any DB fetching the connection will be reopened automatically (with the same connection id) and the StateChange event will not fire. We are not using any connection pooling. I have tried different combinations of .NET framework and SQL Server (not checked in SQL Server 2014)
• Up to SQL Server 2012, it will work in all dot net frameworks
• In SQL Server 2016, this will work only if the framework is 3.5.
Connection string used:
Data Source=DBServer;Network Library=DBMSSOCN;Initial Catalog=DBName; User ID=DBUserName; Password=DBPassword; POOLING=false;Trusted_Connection=false;APPLICATION NAME = STATECHANGE_ISSUE
SQL Server 2016 version
Microsoft SQL Server 2016 (SP1-GDR) (KB4019089) - 13.0.4206.0 (X64) Standard Edition (64-bit)
Did anyone face this issue before? Is there any workaround for this in .Net framework 4.7.
|
|
|
|
|
The odds of you finding someone with a similar hack is zero ... because everyone pools connections.
You seem to have a solution to an "invented" "problem" that now doesn't work. Time to look at pooling more seriously.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
void BtncopyClick(object sender, EventArgs e)
{
string filename=@"E:\\Files\\Reports\\R^ECG^_0_1688^Jones^^_20160711065157_20160711065303 - Copy (4) - Copy.pdf";
string sourcepath=@"E:\\Anusha";
string targetpath=@"E:\\Anusha\\aaa";
string sourcefile= System.IO.Path.Combine(sourcepath,filename);
string destfile= System.IO.Path.Combine(targetpath,filename);
if (!System.IO.Directory.Exists(targetpath))
{
System.IO.Directory.CreateDirectory(targetpath);
}
System.IO.File.Copy(sourcefile, destfile, true);
if (System.IO.Directory.Exists(sourcepath))
{
string[] files = System.IO.Directory.GetFiles(sourcepath);
foreach (string s in files)
{
filename = System.IO.Path.GetFileName(s);
destfile = System.IO.Path.Combine(targetpath, filename);
System.IO.File.Copy(s, destfile, true);
}
}
else
{
MessageBox.Show("File doesn't exist");
}
}
void BtnmoveClick(object sender, EventArgs e)
{
String path = "E:\\Files\\25-11-2017";
String path2 = "E:\\Anusha\\aaa\\25-11-2017";
if (!File.Exists(path))
{
{
using (FileStream fs = File.Create(path)) {}
}
System.IO.Directory.Move("E:\\Files\\25-11-2017",@"E://Anusha//aaa");
File.Move(path, path2);
MessageBox.Show("File Moved");
}
}
i HAVE WRITTEN BELOW code to copy and move the folder ,I am not getting any compiling errors but while i am trying to click on button on output form it was showing as termination.
|
|
|
|
|
Compiling does not mean your code is right!
Think of the development process as writing an email: compiling successfully means that you wrote the email in the right language - English, rather than German for example - not that the email contained the message you wanted to send.
So now you enter the second stage of development (in reality it's the fourth or fifth, but you'll come to the earlier stages later): Testing and Debugging.
Start by looking at what it does do, and how that differs from what you wanted. This is important, because it give you information as to why it's doing it. For example, if a program is intended to let the user enter a number and it doubles it and prints the answer, then if the input / output was like this:
Input Expected output Actual output
1 2 1
2 4 4
3 6 9
4 8 16 Then it's fairly obvious that the problem is with the bit which doubles it - it's not adding itself to itself, or multiplying it by 2, it's multiplying it by itself and returning the square of the input.
So with that, you can look at the code and it's obvious that it's somewhere here:
private int Double(int value)
{
return value * value;
}
Once you have an idea what might be going wrong, start using the debugger to find out why. Put a breakpoint on the first line of the method, and run your app. When it reaches the breakpoint, the debugger will stop, and hand control over to you. You can now run your code line-by-line (called "single stepping") and look at (or even change) variable contents as necessary (heck, you can even change the code and try again if you need to).
Think about what each line in the code should do before you execute it, and compare that to what it actually did when you use the "Step over" button to execute each line in turn. Did it do what you expect? If so, move on to the next line.
If not, why not? How does it differ?
Hopefully, that should help you locate which part of that code has a problem, and what the problem is.
This is a skill, and it's one which is well worth developing as it helps you in the real world as well as in development. And like all skills, it only improves by use!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
OriginalGriff has given you some great advice on how to code, and debug.
Getting in the habit of setting break-points in Visual Studio, and then using F11 to single-step through the code, is a very important thing !
Here are a few suggestions, and code examples, to help you work out what's wrong with your code:
1. check that files, and directories, exist before you them.
2. when you want to automatically create a nested Directory structure:
destfile = System.IO.Path.Combine(targetpath + @"\f2\f3\f4", filename);
if (!Directory.Exists(destfile))
{
new FileInfo(destfile).Directory.Create();
} 3. Your code for 'Move works, but why would you copy a file, and then over-write it when you copy all the files in the same folder ?
Question: is it your intent, here, not to copy internal directories (recursively if nested) ?
«... thank the gods that they have made you superior to those events which they have not placed within your own control, rendered you accountable for that only which is within you own control For what, then, have they made you responsible? For that which is alone in your own power—a right use of things as they appear.» Discourses of Epictetus Book I:12
|
|
|
|
|
BillWoodruff wrote: Question: is it your intent, here, not to copy internal directories (recursively if nested) ?
I do hope not!
string sourcepath=@"E:\\Anusha";
string targetpath=@"E:\\Anusha\\aaa";
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Given the confusion in the OP's code, it seemed reasonable to ask
«... thank the gods that they have made you superior to those events which they have not placed within your own control, rendered you accountable for that only which is within you own control For what, then, have they made you responsible? For that which is alone in your own power—a right use of things as they appear.» Discourses of Epictetus Book I:12
|
|
|
|
|
Your "Path.Combines" don't make sense.
Your file names are "full file names" and cannot be "combined".
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
Hello everyone, I really need help about problem with loading of WaveFrontLoader.cs
I have tried to load obj but GameWindow doesn't show model why because it has nothing any errors.
I really want to have resolve WaveFront on my GameWindow
I will show code and file:
using OpenTK;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
namespace Tutorial_08.net.sourceskyboxer
{
public class WaveFrontLoader
{
private static List<Vector3> inPositions;
private static List<Vector2> inTexcoords;
private static List<Vector3> inNormals;
private static List<float> positions;
private static List<float> texcoords;
private static List<int> indices;
public static RawModel LoadObjModel(string filename, Loader loader)
{
inPositions = new List<Vector3>();
inTexcoords = new List<Vector2>();
inNormals = new List<Vector3>();
positions = new List<float>();
texcoords = new List<float>();
indices = new List<int>();
int nextIdx = 0;
using (var reader = new StreamReader("Contents/" + filename + ".obj", Encoding.UTF8))
{
string line = reader.ReadLine();
while (true)
{
string[] currentLine = line.Split(new[] { ' ' }, StringSplitOptions.None);
if (currentLine[0] == "v")
{
Vector3 pos = new Vector3(float.Parse(currentLine[1]), float.Parse(currentLine[2]), float.Parse(currentLine[3]));
inPositions.Add(pos);
if (currentLine[1] == "t")
{
Vector2 tex = new Vector2(float.Parse(currentLine[1]), float.Parse(currentLine[2]));
inTexcoords.Add(tex);
}
if (currentLine[1] == "n")
{
Vector3 nom = new Vector3(float.Parse(currentLine[1]), float.Parse(currentLine[2]), float.Parse(currentLine[3]));
inNormals.Add(nom);
}
}
if (currentLine[0] == "f")
{
Vector3 pos = inPositions[0];
positions.Add(pos.X);
positions.Add(pos.Y);
positions.Add(pos.Z);
Vector2 tc = inTexcoords[0];
texcoords.Add(tc.X);
texcoords.Add(tc.Y);
indices.Add(nextIdx);
++nextIdx;
}
reader.Close();
return loader.loadToVAO(positions.ToArray(), texcoords.ToArray(), indices.ToArray());
}
}
}
}
}
in Game.cs:
loader = new Loader();
shader = new StaticShader();
renderer = new Renderer(shader);
model = WaveFrontLoader.LoadObjModel("example", loader);
texturedModel = new TexturedModel(model, new ModelTexture(loader.loadTexture("example")));
entity = new Entity(texturedModel, new Vector3(0, 0, -40), 0, 0, 0, 1);
camera = new Camera();
Download myproblem.7z from mega.nz
How do I resolve if wavefront obj displays in GameWindow Thank you for checking and resolving.
Please promise me! I want listen how do I get working wavefrontloader.cs should parse to obj file. Thank you!
I am very broken since Sunday to today I can not resolve it cause WavefrontLoader can know Obj but doesn't show in GameWindow. How do I get successful loading obj. But it is really porting from LwjGL into C# OpenTK. Thanks for help!
|
|
|
|
|
|
Why do you use old OpenTK?
STOP PLEASE CHECK CAREFUL BECAUSE VERY LATEST VERSION of OPENTK from Github and MyGet Server That is not old.
For Neo Kabuto is very same to CrazyCore ( like it looks like you have played Valve Hammer Editor with unlimited edges with very large face like broken object made biggest faces like it seems "error-faces" )
That is same I have played Neo Kabuto's last tutorial 8 Step 2 = 2 planes and 1 television ( it happens unlimited face ( = error-face ) for latest OpenTK cause object looks like Half-Life-style binary structure ( bsp 30 version and for object is broken with error-faces.
If you don't know about error-faces?
What is an error-face?
Example like CrazyCore in game happens
Picture 1
Picture 2
That is really bad.
But I found SharpGL's ObjFileLoader.cs
It is really very old for OpenTK.
How do I understand for structure of wavefront file ( obj )
Please explain current for very latest version with while loop-like compilication!
That is very hard because latest version = unknown
old version = same version.
If it happens with Blender'S wavefront is buggy or stable. I am not sure Please check who has exported successful with 3D Max or 3D GameStudio-ModelEditor or Milkshape or Softimage XSI and other
What is wavefront version for now? If it is same old or newest version?
That is reason.
I need know how does latest OpenTK read Wavefront file?
If you have tried wavefront in my example ( Tutorial_08 ) Did you try obj in GameWindow to show - If it is still not visible than it means buggy or I write wrong while-loop?
Thank you for explanation!
Thank you!
|
|
|
|
|
Less coffee.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|