all groups > vj# > may 2005 >
You're in the

vj#

group:

Problems with SQL.


Problems with SQL. Christian-Josef Schrattenthaler
5/23/2005 12:00:00 AM
vj#: Hi!

I want to make a logfile for my login-page (login-page allready works). I
use a MDB file which contains a table for each month. In the tables ar the
fields: Id, Datum, Uhrzeit, EMailAdresse and Kundennummer.

I tried to create the code, but I didn't understand some things. I marked
them with "???". And I can't find the end for the sql-command, this means
the sending of the sql-command.

Here is my code:

***
void Page_Load(Object sender, System.EventArgs e) {

// Aktuelle Uhrzeit in dtTemp speichern:
DateTime dtTemp = DateTime.get_Now();

// Benötigte Daten:
// """"""""""""""""
// Monat: month
// Datum: date
// Uhrzeit: time
// EMailAdresse: email
// Kundennummer: kdnr
String month = dtTemp.ToString("MMMM");
String date = dtTemp.ToString("yyyy-mm-dd");
String time = dtTemp.ToString("HH:mm:ss");
String email = "info@businessname.com";
String kdnr = "20001";

// Gesammelte Daten am Bildschirm ausgeben:
get_Response().Write(month +"<br>");
get_Response().Write(date +"<br>");
get_Response().Write(time +"<br>");
get_Response().Write(email +"<br>");
get_Response().Write(kdnr +"<br>");

// Die Zugriffsart und die Datenbank festlegen:
String myCon = "Provider=Microsoft.Jet.OLEDB.4.0;";
myCon += "Data Source=C:/Inetpub/wwwroot/test/cjsTest_3/db1.mdb;";

// ???
OleDbConnection dbcon = new OleDbConnection(myCon);

// ???
dbcon.Open();

// Den SQL-Befehl erzeugen:
String sqlCommand = "INSERT INTO " +month +" (Datum, Uhrzeit,
EMailAdresse, Kundennummer) ";
sqlCommand += "VALUES (" +date +", " +time +", " + email +", " +kdnr
+")";

// sqlCommand am Bildschirm ausgeben:
get_Response().Write(sqlCommand);

// ???
OleDbCommand dbcom = new OleDbCommand(sqlCommand,dbcon);

//
// ???
//

//
dbcon.Close();

}
***

Can anyone help me?

Thanks and greetings,
christian.

Re: Problems with SQL. Christian-Josef Schrattenthaler
5/24/2005 12:00:00 AM
I could resolve the problem!
Now I have only to do some tuning...

Greetings,
Re: Problems with SQL. Lars-Inge Tønnessen [VJ# MVP]
5/24/2005 12:00:00 AM

[quoted text, click to view]

Cool! :o)

All you where missing was the call to execute the SQL statement.

Database programming from .NET requires in general.

1. A connection.
2. That you open the connection.
3. Write a SQL command
4. Connect the SQL command to the connection
5. Execute the command
6. Close the connection.

Your "String sqlCommand " is just a text string to hold the SQL command
text. This is not the SQL command in it self. This "OleDbCommand dbcom = new
OleDbCommand(sqlCommand,dbcon);" is your real command.

This "OleDbConnection dbcon = new OleDbConnection(myCon);" is your
connection to the database.


[quoted text, click to view]

In general using a Access database on the web is not recommended (by me
o) ). It's a single user database with a very low performance. I will
recommend using MS SQL Server or the smaller (MS SQL Server) MSDE (or MS SQL
Server Express 2005). You will get a world class database performance with
the MSDE.

Please read my article:
http://www.codeproject.com/database/ConfigureMSDE.asp


Regards,
Lars-Inge Tønnessen

Re: Problems with SQL. Christian-Josef Schrattenthaler
5/24/2005 12:00:00 AM
Hi Lars-Inge!

[quoted text, click to view]

I use a Microsoft Small Business Server 2003 Premium Edition. This means,
the MS-SQL is installed and running. This time only for SHAREPOINT and
ARCSERVER BACKUP.

But my problem is:

1. I dont't know how the MS-SQL really works.

2. I need one database system for a log-file-system, which can easyly
viewed.

3. I need one database system to create only a list on the screen. This
means, that a usere uses an access-database to manage his adresses, and he
puts the access-database via ftp-client on the server, every the latest
version, and if anyone wants to look to the adresses, then my asp.net site
has to create an output.

So I think, that I could't use MS-SQL. But if you think, I am not right,
please tell me...

Greetings,
christian.

Re: Problems with SQL. Lars-Inge Tønnessen [VJ# MVP]
5/24/2005 12:00:00 AM

[quoted text, click to view]

Excellent choice! We are running that server in the BMW Car Club Norway too.
:o)

In that case I guess you have to use the JET/Access.


Regards,
Lars-Inge Tønnessen

Re: Problems with SQL. Christian-Josef Schrattenthaler
5/25/2005 12:00:00 AM
Hi Lars-Inge!

[quoted text, click to view]

I know, but there is many to do, if the server should run clearly. The
SBS2003 is also the reason, why I want to change my PHP-Sites to
ASP.NET!

[quoted text, click to view]

This means I should use my Access-Database-Files, oder I should use
MS-SQL?

Greetings,
christian.
AddThis Social Bookmark Button