|
hi everyone.
im new here and currently i need help in my final year school project.
I have to create log in GUI which i have to connect it to Microsoft Access, where the database is.
it's when a user wants to log in, the program will compare with the database and confirm whether or not the user is authorized.
not only that, i have to do searching,sorting, adding and deleting of users. and it must be connected with the database.
another thing, does any of you know what is the codes to connect one form to another form?
i will be really glad if any one of you able to help me with my school project.
thank you and hope to hear from any of you soon.
|
|
|
|
|
So what are the problems you're experiencing?
* The database connection?
* Running the query for authorizing a user?
* Queries for searching, adding, sorting, deletion?
The question of how to pass data between Windows Forms keep coming up here every now and then and I'm sure you'll find the answer if you search CodeProject.
Good luck!
|
|
|
|
|
the problems that im experiencing is the database connection. when i try to debug it, it cant debug. and the weird thing i do not have any error.
but when i debug, it show the vlAccessConnection.Open () and higlighted it in yellow and it said that it can't find the file when i have already copy the file in the debug file.
here's some of the codes.
vlAccessConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source= data.mdb" + DBFileName);
vlAccessConnection.Open();
i have been trying for days. and im stuck at this part.
pls help me. thank you. (:
|
|
|
|
|
I think your connection string looks a bit weird. You set Source= data.mdb and then you append some variable called DBFileName . What is the resulting path of that? Isn't data.mdb your database file? Based on the info you have provided this is probably what's causing the problem. Check your conn string again (maybe have a look at this link as well.
|
|
|
|
|
Hi,
I have to develop a c# application, which is simulates a pdf viewer. Any suggestion is appreciated.
Thank you.
|
|
|
|
|
|
hi,
that was a funny reply. anyways before posting question in this website, I do search google, when I don;t get articles that could serve my purpose then I post a question.
|
|
|
|
|
If you only want to simulate a PDF viewer, then you could start Adobe Reader, passing the file name as a parameter. Then you could use the Windows API to make the new window a child of your current Form.
|
|
|
|
|
<?xml version="1.0" encoding="utf-8"?>
<dataConfiguration>
<xmlSerializerSection type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
<enterpriseLibrary.databaseSettings xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" defaultInstance="Database Instance" xmlns="http://www.microsoft.com/practices/enterpriselibrary/08-31-2004/data">
<databaseTypes>
<databaseType name="Sql Server" type="Microsoft.Practices.EnterpriseLibrary.Data.Sql.SqlDatabase, Microsoft.Practices.EnterpriseLibrary.Data, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
</databaseTypes>
<instances>
<instance name="Database Instance" type="Sql Server" connectionString="Server=awsqlt25vs01;Database=SW2_phone_interview;Integrated Security=true;" />
</instances>
<connectionStrings>
<connectionString name="Server=awsqlt25vs01;Database=SW2_phone_interview;Integrated Security=true;">
<parameters>
<parameter name="database" value="SW2_phone_interview" isSensitive="false" />
<parameter name="Integrated Security" value="true" isSensitive="false" />
<parameter name="server" value="awsqlt25vs01" isSensitive="false" />
</parameters>
</connectionString>
</connectionStrings>
</enterpriseLibrary.databaseSettings>
</xmlSerializerSection>
</dataConfiguration>
I have the above code snippet in my windows application. Now in some methods I am getting tome out exception. So I need to add one more instance for Microsoft.Practices.EnterpriseLibrary.Data.SQL.SQLCommandWrapper to set the connection time out property for a constant value in config file
Please advise
Thanks in advance.
-
|
|
|
|
|
gday all.
i am getting this error:
Error: System.NullReferenceException: Object reference not set to an instance of an object.
at Keystore.FindKey.FindKey_Load(Object sender, EventArgs e) in C:\Users\Shane\Documents\Visual Studio 2008\Projects\Keystore1\Keystore1\FindKey.cs:line 89
when running this code:
private void FindKey_Load(object sender, EventArgs e)
{
SqlCommand command;
DataTable dt;
try
{
SqlConnection con = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|\\KeyStore.mdf;Integrated Security=True;User Instance=True");
}
catch (Exception ex)
{
MessageBox.Show("Error: " + ex);
}
try
{
con.Open();
}
catch (Exception ex)
{
MessageBox.Show("Error: " + ex);
}
try
{
command = new SqlCommand("SELECT * FROM Key", con);
}
catch (Exception ex)
{
MessageBox.Show("Error: " + ex);
command = new SqlCommand("SELECT * FROM Key", con);
}
try
{
dt = new DataTable();
}
catch (Exception ex)
{
MessageBox.Show("Error: " + ex);
dt = new DataTable();
}
try
{
SqlDataAdapter da = new SqlDataAdapter(command);
}
catch (Exception ex)
{
MessageBox.Show("Error: " + ex);
}
try
{
da.Fill(dt);
}
catch (Exception ex)
{
MessageBox.Show("Error: " + ex);
}
try
{
for (int i = 0; i < dt.Rows.Count; i++)
{
DataRow dRow = dt.Rows[i];
FoundKey newkey = new FoundKey(dRow);
lstMatchedKeys.Items.Add(newkey);
}
}
catch (Exception ex)
{
MessageBox.Show("Error: " + ex);
}
try
{
con.Close();
}
catch (Exception ex)
{
MessageBox.Show("Error: " + ex);
}
}
sorry for all the try/catch's. been using them to try and pinpoint the error and the error message.
The error is coming from the "da.Fill(dt);" line. The rest runs ok.
Can anyone help me overcome this problem? =)
|
|
|
|
|
Does that compile? It shouldn't. Your con is local to a try block and isn't accessable to the other statements.
If it does compile then change SqlConnection con = new SqlConnection ... to con = new SqlConnection ...
|
|
|
|
|
snayler0 wrote: sorry for all the try/catch's. been using them to try and pinpoint the error and the error message.
Do you know how to use a debugger?
try
{
command = new SqlCommand("SELECT * FROM Key", con);
}
catch (Exception ex)
{
MessageBox.Show("Error: " + ex);
command = new SqlCommand("SELECT * FROM Key", con);
}
If the first time you tried creating the command threw an exception, why do you think trying it again won't do the same thing?
It would be more help you just looked at line 89, or told us which line it was.
only two letters away from being an asset
|
|
|
|
|
yeah, lol sorry bout that.
i had already found that line to not be causing any problems, but because command was being defined locally in the try block, it wasnt accepting it further down, because there was a chance it would be undefined (if there was an exception) and wouldn't compile because of it. so i just threw them i nthe catch as well since i knew those particular parts were working, (instead of doing away with the try/catch's for those parts alltogether)
the only place an exception is coming up from is:
try
{
da.Fill(dt);
}
catch (Exception ex)
{
MessageBox.Show("Error: " + ex);
}
|
|
|
|
|
after removing all the try/catch's that weren't needed anymore, i have recieved a different error (on the same line ( da.Fill(dt); )
the error is now SQL specific... but i think my syntax looks fine.. be prepared... its a long error message, here it is:
Error: System.Data.SqlClient.SqlException: Incorrect syntax near the keyword 'Key'.
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
at System.Data.SqlClient.SqlDataReader.ConsumeMetaData()
at System.Data.SqlClient.SqlDataReader.get_MetaData()
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable)
at Keystore.FindKey.FindKey_Load(Object sender, EventArgs e) in C:\Users\Shane\Documents\Visual Studio 2008\Projects\Keystore1\Keystore1\FindKey.cs:line 46
|
|
|
|
|
Yup your datatable dt is null.
datatable dt = new Datatable();
|
|
|
|
|
Thanks for that, i hadnt noticed.
ive changed it to
dt = new DataTable("AllKeys");
since this table should be filling with all the keys in the database.
But i am still getting the error mentioned in my previous post.
it doesnt like the syntax of
command = new SqlCommand("SELECT * FROM Key", con); near the keyword 'Key'.
it isnt picking up this error until i try to execute the line:
da.Fill(dt);
|
|
|
|
|
the word 'Key' is a keyword in SQL Server and should not be used as an object name. You could enclose it in [] but it is best to change the name of your table (as you have found). The following will work but is not recommended.
command = new SqlCommand("SELECT * FROM [Key]", con);
If you have SQL Server Management Studio (SSMS), test your scripts in SSMS before implementing in VS, you will get much better information and feedback from SSMS.
|
|
|
|
|
I am currently studying XNA.
Is there any convenient way to recognize mouse gesture?
For example, how to tell whether I have draw a circle clockwise.
|
|
|
|
|
There's nothing specific in XNA over regular C#. There's an example here[] you could look at
|
|
|
|
|
I am sorry. Which example?
|
|
|
|
|
Sorry, looks like the forum ate my link!
http://www.codeproject.com/KB/recipes/cmgblade.aspx
|
|
|
|
|
I'm writing a small telnet-based app that connects to a *nix box, executes some commands and displays the output. When the user is logged on, several scripts run requiring user input and the set of scripts are different for each box (so I can't just hardcode responses).
It seems like the best solution is to break out of the scripts and do their work myself but I can't figure out how to send the Ctrl-C character to do this. Any ideas?
|
|
|
|
|
Character 3 -- but I suggest you try communicating with the scripts properly. I've written code that automates a Telnet session; what problem are you having?
|
|
|
|
|
Primarily I was hoping to create a GUI application that required no user input other than hostname, username and password. We deal with different flavors of *nix, and each one reacts to commands slightly differently, plus these login scripts can be different on each machine.
Essentially, since I know what all the settings to should be, I figured it was easier just to break out of the scripts and set the environments myself rather than deal with all the parsing necessary but I realize that's me being a bit lazy .
|
|
|
|
|
zenlc2000 wrote: create a GUI application that required no user input other than hostname, username and password.
What's the point?
I had to write a Windows Service (therefore no user input, just configuration) to interact with a character-based third-party product on SCO Unix.
I wrote my own simple scripting language to do it. I expect a similar technique could be used in your situation.
|
|
|
|