|
Most people create a format to define missions, and then write a program with which they can create as many missions as they like, just by creating new data files.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
thanks for ur explanation. but i still need some sample or tutorial to understand the concept... cud u give me some link to such kind of tutorial... i hav searched in google for about 15 minutes and havnt found any...
|
|
|
|
|
How it works, is up to you. I'm not going to write a game to show you. You could look to see if the XNA framework has any samples you can look at.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
|
Sorry but if i understand your question you want to store how many things you need to shoot and how long to do in?
well just use some variables, get from a file or something. simple file with level, target, time would do, i.e.
1-10-60
2-15-55
3-20-50
4-25-45
etc.
then for each level you load your target and time
My opinion is... If someone has already posted an answer, dont post the SAME answer
|
|
|
|
|
|
|
Hi expert ,
this is login code with Mysql Connectivity .it is not working.
no error is showing
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MySql.Data.MySqlClient;
namespace ExampleOne
{
public partial class login : Form
{
public login()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void textBox2_TextChanged(object sender, EventArgs e)
{
}
private void btnlogin_Click(object sender, EventArgs e)
{
string g_login = this.tbUsername.Text;
string g_password = this.tbpassword.Text;
string MyConString = "server=localhost;database=password;uid=root;password=asd";
MySqlConnection connection = new MySqlConnection(MyConString);
string Strsql = "select * from tablogin where userid = ' " + g_login + " 'AND password=' " + g_password + " ' ";
MySqlCommand command = new MySqlCommand(Strsql, connection);
MySqlDataReader Reader;
try
{
connection.Open();
Reader = command.ExecuteReader();
while (Reader.Read())
{
string auser;
string apwd;
auser = (Reader[g_login].ToString());
apwd = (Reader[g_password].ToString());
if (auser == g_login && apwd == g_password)
{
MessageBox.Show("INCORRECT USER/PASS!");
}
else
{
MessageBox.Show("YOU ARE LOGGED IN!");
}
}
connection.Close();
}
catch (Exception ex)
{
Console.WriteLine("Error Conecting to database", "window information" + ex.Message.ToString(),
MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
}
|
|
|
|
|
Your code is really, really crappy. I can erase your database any time I like. Apart from that, hard to say, given that you don't tell us what code executes, what you see, what happens, etc. Do you know how to use the debugger ? Any execution path should show a message box, so more detail than 'it's not working' should be easy to offer, even if you don't know how to debug code.
Also, the right way to check a login is to do a select count(*), not to get the username and password returned.
Oh, I see the issue.
ashish1nov2008 wrote: while (Reader.Read())
So, if nothing is returned, you won't see anything. Duh.
ashish1nov2008 wrote: else
{
MessageBox.Show("YOU ARE LOGGED IN!");
}
This can never execute, by definition.
Look at your SQL, make sure what you're typing in is correct ( for example, is there a trailing space in the DB and not in your text ? Can you think of ways to make that not matter ?
I think you need to read a basic C# book and start again.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Ooops SQL Injection
string Strsql = "select * from tablogin where userid = ' " + g_login + " 'AND password=' " + g_password + " ' ";
This is How you Should do it
First you have to Create a Storedprocure that counts the Records that match the username and password,
Create Procedure prclogin_check
(
@User_name varchar(20),
@U_Password varchar(23),
@Results int Output
)
IF EXISTS (Select * from User_Table
where User_name =@User_name and U_Password = @U_Password)
Set @Results =1
And after you are done with this , you have to do the Following in your C# Code
using System.Data.SqlClient;
String strcon = "User id = sa;Password= topman;Server=myServer;Database=MyDB";
SqlConnection con = new SqlConnection(strcon);
SqlCommand cmdselect = new SqlCommand();
cmdselect.CommandTimeout = 0;
cmdselect.CommandType = CommandType.StoredProcedure;
cmdselect.Connection = con;
cmdselect.CommandText = "prclogin_check";
cmdselect.Parameters.Add("@Results",SqlDbType.Int,4);
cmdselect.Parameters["@Results"].Direction = ParameterDirection.Output;
int Res;
try
{
con.Open();
cmdselect.ExecuteNonQuery();
Res = (int)cmdselect.Parameters["@Results"].Value;
con.Close();
}
catch (SqlException e)
{
MessageBox.Show(e.Message);
}using System.Data.SqlClient;
String strcon = "User id = sa;Password= topman;Server=myServer;Database=MyDB";
SqlConnection con = new SqlConnection(strcon);
SqlCommand cmdselect = new SqlCommand();
cmdselect.CommandTimeout = 0;
cmdselect.CommandType = CommandType.StoredProcedure;
cmdselect.Connection = con;
cmdselect.CommandText = "prclogin_check";
cmdselect.Parameters.Add("@Results",SqlDbType.Int,4);
cmdselect.Parameters["@Results"].Direction = ParameterDirection.Output;
int Res;
try
{
con.Open();
cmdselect.ExecuteNonQuery();
Res = (int)cmdselect.Parameters["@Results"].Value;
con.Close();
}
catch (SqlException e)
{
MessageBox.Show(e.Message);
}
And in your Business logic or in your Form you can create a Function that will test if the Count of Records is greater than 0,if its less than that , then its invalid login
Hope this Helps
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.tiyaneProperties.co.za
vuyiswam@its.co.za
|
|
|
|
|
hi, i looked up googles and everywhere.. but i couldn't solve the problem
this is my codes.
since i searched the gooles, lots of people say if you have "GetResponse() hang" it's because you didn't close the Response. but this cann't be my situation. Because, in my case, a timer has to run every 5 seconds so i can't do
" Response.close()". does anybody have any ideas??
[STAThread]
public static void Main(string [] args)
{
Application.Run(new HealthMon());
}
private void HealthMon_Load(object sender, System.EventArgs e)
{
this.CheckTimer.Interval = 5000;
this.CheckTimer.Start();
}
private void CheckTimer_Tick(object sender, System.EventArgs e)
{
System.Net.WebRequest request = null;
System.Net.HttpWebResponse response = null;
try
{
request = System.Net.WebRequest.Create("http://url.....");
response = (System.Net.HttpWebResponse)request.GetResponse();
GlobalProxySelection.Select = WebProxy.GetDefaultProxy();
if(response.StatusCode != HttpStatusCode.OK)
{
MessageBox.show("error");
}
else
{
MessageBox.show("success");
}
}
catch( Exception ex )
{
MessageBox.show("error");
}
}
|
|
|
|
|
Chances are if GetResponse() hangs, you have not recieved a response. Try putting in some different urls and see what happens. Also, have you configured your proxy correctly?
Regards,
Rob Philpott.
|
|
|
|
|
I have tried diffrent urls.. like localhost, and the other PC that is right next to me..
and I don't have proxy settings..
they all hangs... -_-
|
|
|
|
|
Don't know then. I've tried your code slightly modified (below) and it works fine. Suspicion turns to the timer. If you call this just once from Main rather than repeatedly, does it work?
public static void Main(string[] args)
{
System.Net.WebRequest request = null;
System.Net.HttpWebResponse response = null;
request = System.Net.WebRequest.Create("http://news.bbc.co.uk");
WebProxy p = new WebProxy("...our proxy", true);
p.UseDefaultCredentials = true;
request.Proxy = p;
response = (System.Net.HttpWebResponse)request.GetResponse();
}
Regards,
Rob Philpott.
|
|
|
|
|
yes! it only works for 2times.
the third time... hangs.. -_-
sometimes it goes more then two times, but the result is the same eventually..
|
|
|
|
|
Then something isn't clearing up properly. Are you using a Windows Forms timer? I'm wondering if the Response stream needs to be disposed or something. Will have a play...
Regards,
Rob Philpott.
|
|
|
|
|
I've managed to reproduce it, it hangs on the second time. As I just eluded to, its because your response stream doesn't get disposed.
Stick this after you call GetResponse() and I think you'll be ok:
response.GetResponseStream().Dispose();
Regards,
Rob Philpott.
|
|
|
|
|
#define P 0x8408
main()
{
register unsigned int b, v;
register int i;
printf("typedef unsigned short u16;\n");
printf("static u16 fcstab[256] = {");
for (b = 0; ; ) {
if (b % 8 == 0)
printf("\n");
v = b;
for (i = 8; i--; )
v = v & 1 ? (v >> 1) ^ P : v >> 1;
printf("\t0x%04x", v & 0xFFFF);
if (++b == 256)
break;
printf(",");
}
printf("\n};\n");
}
===> C# ?!?
|
|
|
|
|
Actually, it would look pretty much the same, except that you would replace printf with Console.WriteLine
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
<code>
static int Main()
{
//C++ TO C# CONVERTER NOTE: 'register' variable declarations are not supported in C#:
//ORIGINAL LINE: register uint b, v;
uint b;
uint v;
//C++ TO C# CONVERTER NOTE: 'register' variable declarations are not supported in C#:
//ORIGINAL LINE: register int i;
int i;
Console.Write("typedef unsigned short u16;\n");
Console.Write("static u16 fcstab[256] = {");
for (b = 0;
{
if (b % 8 == 0)
Console.Write("\n");
v = b;
for (i = 8; i--;)
v = v & 1 ? (v >> 1) ^ DefineConstants.P : v >> 1;
Console.Write("\t0x{0:x4}", v & 0xFFFF);
if (++b == 256)
break;
Console.Write(",");
}
Console.Write("\n};\n");
}
internal sealed class DefineConstants
{
public const int P = 0x8408;
}
</code>
David Anton
http://www.tangiblesoftwaresolutions.com
C++ to C# Converter
C++ to VB Converter
C++ to Java Converter
VB & C# to Java Converter
Java to VB & C# Converter
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: convert VB, C#, or Java to C++
|
|
|
|
|
Is there some sort of black magic to keep code snippets from being butchered here?
The 'code' tags don't appear to actually do anything and even though I un-selected 'auto-encode...', I still get the ridiculous emoticons...
David Anton
http://www.tangiblesoftwaresolutions.com
C++ to C# Converter
C++ to VB Converter
C++ to Java Converter
VB & C# to Java Converter
Java to VB & C# Converter
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: convert VB, C#, or Java to C++
|
|
|
|
|
Hi all,
One of my server application I've log all information into text files, on my own pattern.
For ease of use I'm going to write an application to analyze the log. What I'm looking to do is, read the text file line-by-line and match some strings. Depends on that validation doing different process and display, may be on a UI.
Is that way is effective. Comments are really appreciate.
Thanks
I appreciate your help all the time...
CodingLover
|
|
|
|
|
Hi,
you can use regular expressions to match the strings. For defining different processes depending on that validation I would suggest using the strategy pattern.
Should the logfile analysed only once? If not you have to find a mechanism so that you knwo which line you already read and which not.
Regards
Sebastian
|
|
|
|
|
Hi,
Thanks for commenting
Actually log file analyze only once. Later I want to compare two logs, say for socket and internal process something.
I've think about one thing. Read the whole file once and store all line in a collection framework. But I want to choose which is the best.
I appreciate your help all the time...
CodingLover
|
|
|
|
|
Wll reading the whole one file once and storing them in a collection will be very memory and time consuming I think. If this is not a problem for you then go on, but if it is... depending on the comparison you want to do I would try sth with reading line by line (without storing) etc.
|
|
|
|