473,698 Members | 2,339 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help! Why my code can not write string to MDB ?

i need your help, my code as below :
//-----------------------------------------------------------------------
//Wrote by Michael April 30 2005
//-----------------------------------------------------------------------

using System.Text;
using System.Diagnost ics;
using System.Threadin g;
using System;
using System.Text.Reg ularExpressions ;
using System.Data.Ole Db;

public class LogInfo4
{
public static void Main(String[] args)
{

string log="System";
string machine="MyDC00 1";
EventLog aLog = new EventLog();
aLog.Log = log;
aLog.MachineNam e = machine;

Console.WriteLi ne("There are {0} entr[y|ies] in the log:",
aLog.Entries.Co unt);
//get string for print Message
foreach (EventLogEntry entry in aLog.Entries)
{

string strText = entry.Message;
string PrintDocNum,
PrintDocName,Pr intUser,PrintSe rverName,PrintB yte,PrintIp,Pri ntPages;
string strMatch = @"^Document (\d+), *(.+) owned by (.+) was printed on
(.*) via port IP_(\d{1,3}\.\d {1,3}\.\d{1,3}\ .\d{1,3})\. Size in bytes:
(\d+); pages printed: (\d+)";
Regex re = new Regex(strMatch) ;
Match m = re.Match(strTex t);
if(m.Success)
{
PrintDocNum = m.Groups[1].ToString();
PrintDocName = m.Groups[2].ToString();
PrintUser = m.Groups[3].ToString();
PrintServerName = m.Groups[4].ToString();
PrintIp = m.Groups[5].ToString();
PrintByte = m.Groups[6].ToString();
PrintPages = m.Groups[7].ToString();
OleDbConnection conn = new OleDbConnection ();
// TODO: Modify the connection string and include any
// additional required properties for database.
conn.Connection String = @"Provider=Micr osoft.Jet.OLEDB .4.0;" +
@"Data source= E:\April30\Db\T estDb.mdb" ;
conn.Open();
string sqlInsert=@"ins ert into
TestTable(DocNu m,DocName,User, ServerName,Byte ,Ip,Pages) values
(@PrintDocNum,@ PrintDocName,@P rintUser,@Print ServerName,@Pri ntByte,@PrintIp ,@PrintPages)";
OleDbCommand cmd1=new OleDbCommand(sq lInsert,conn);
cmd1.Parameters .Add("@PrintDoc Num",System.Dat a.OleDb.OleDbTy pe.VarChar,50,P rintDocNum);

cmd1.Parameters .Add("@PrintDoc Name",System.Da ta.OleDb.OleDbT ype.VarChar,50, PrintDocName);
cmd1.Parameters .Add("@PrintUse r",System.Data. OleDb.OleDbType .VarChar,50,Pri ntUser);
cmd1.Parameters .Add("@PrintSer verName",System .Data.OleDb.Ole DbType.VarChar, 50,PrintServerN ame);
cmd1.Parameters .Add("@PrintByt e",System.Data. OleDb.OleDbType .VarChar,50,Pri ntByte);
cmd1.Parameters .Add("@PrintIp" ,System.Data.Ol eDb.OleDbType.V arChar,50,Print Ip);
cmd1.Parameters .Add("@PrintPag es",System.Data .OleDb.OleDbTyp e.VarChar,50,Pr intPages);
//Console.WriteLi ne("Command Created");
cmd1.ExecuteNon Query();//insert string
//Console.WriteLi ne("insert end");
conn.Close();
}

}
}
}
Nov 17 '05 #1
2 1441
hi

where r u getting the error?

did you try to insert the same values directly in access?

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"roopeman" <ro******@discu ssions.microsof t.com> wrote in message
news:F7******** *************** ***********@mic rosoft.com...
i need your help, my code as below :
//-----------------------------------------------------------------------
//Wrote by Michael April 30 2005
//-----------------------------------------------------------------------

using System.Text;
using System.Diagnost ics;
using System.Threadin g;
using System;
using System.Text.Reg ularExpressions ;
using System.Data.Ole Db;

public class LogInfo4
{
public static void Main(String[] args)
{

string log="System";
string machine="MyDC00 1";
EventLog aLog = new EventLog();
aLog.Log = log;
aLog.MachineNam e = machine;

Console.WriteLi ne("There are {0} entr[y|ies] in the log:",
aLog.Entries.Co unt);
//get string for print Message
foreach (EventLogEntry entry in aLog.Entries)
{

string strText = entry.Message;
string PrintDocNum,
PrintDocName,Pr intUser,PrintSe rverName,PrintB yte,PrintIp,Pri ntPages;
string strMatch = @"^Document (\d+), *(.+) owned by (.+) was printed on
(.*) via port IP_(\d{1,3}\.\d {1,3}\.\d{1,3}\ .\d{1,3})\. Size in bytes:
(\d+); pages printed: (\d+)";
Regex re = new Regex(strMatch) ;
Match m = re.Match(strTex t);
if(m.Success)
{
PrintDocNum = m.Groups[1].ToString();
PrintDocName = m.Groups[2].ToString();
PrintUser = m.Groups[3].ToString();
PrintServerName = m.Groups[4].ToString();
PrintIp = m.Groups[5].ToString();
PrintByte = m.Groups[6].ToString();
PrintPages = m.Groups[7].ToString();
OleDbConnection conn = new OleDbConnection ();
// TODO: Modify the connection string and include any
// additional required properties for database.
conn.Connection String = @"Provider=Micr osoft.Jet.OLEDB .4.0;" +
@"Data source= E:\April30\Db\T estDb.mdb" ;
conn.Open();
string sqlInsert=@"ins ert into
TestTable(DocNu m,DocName,User, ServerName,Byte ,Ip,Pages) values
(@PrintDocNum,@ PrintDocName,@P rintUser,@Print ServerName,@Pri ntByte,@PrintIp ,@PrintPages)";
OleDbCommand cmd1=new OleDbCommand(sq lInsert,conn);
cmd1.Parameters .Add("@PrintDoc Num",System.Dat a.OleDb.OleDbTy pe.VarChar,50,P rintDocNum);

cmd1.Parameters .Add("@PrintDoc Name",System.Da ta.OleDb.OleDbT ype.VarChar,50, PrintDocName);
cmd1.Parameters .Add("@PrintUse r",System.Data. OleDb.OleDbType .VarChar,50,Pri ntUser);
cmd1.Parameters .Add("@PrintSer verName",System .Data.OleDb.Ole DbType.VarChar, 50,PrintServerN ame);
cmd1.Parameters .Add("@PrintByt e",System.Data. OleDb.OleDbType .VarChar,50,Pri ntByte);
cmd1.Parameters .Add("@PrintIp" ,System.Data.Ol eDb.OleDbType.V arChar,50,Print Ip);
cmd1.Parameters .Add("@PrintPag es",System.Data .OleDb.OleDbTyp e.VarChar,50,Pr intPages);
//Console.WriteLi ne("Command Created");
cmd1.ExecuteNon Query();//insert string
//Console.WriteLi ne("insert end");
conn.Close();
}

}
}
}

Nov 17 '05 #2
Hi,Ignacio, it 's end at "send error to Microsoft or not" pop menu, i can
insert the same
values to Mdb manually.and i am beginner in C#,Would please take a carefully
check
at my code?

"Ignacio Machin ( .NET/ C# MVP )" wrote:
hi

where r u getting the error?

did you try to insert the same values directly in access?

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"roopeman" <ro******@discu ssions.microsof t.com> wrote in message
news:F7******** *************** ***********@mic rosoft.com...
i need your help, my code as below :
//-----------------------------------------------------------------------
//Wrote by Michael April 30 2005
//-----------------------------------------------------------------------

using System.Text;
using System.Diagnost ics;
using System.Threadin g;
using System;
using System.Text.Reg ularExpressions ;
using System.Data.Ole Db;

public class LogInfo4
{
public static void Main(String[] args)
{

string log="System";
string machine="MyDC00 1";
EventLog aLog = new EventLog();
aLog.Log = log;
aLog.MachineNam e = machine;

Console.WriteLi ne("There are {0} entr[y|ies] in the log:",
aLog.Entries.Co unt);
//get string for print Message
foreach (EventLogEntry entry in aLog.Entries)
{

string strText = entry.Message;
string PrintDocNum,
PrintDocName,Pr intUser,PrintSe rverName,PrintB yte,PrintIp,Pri ntPages;
string strMatch = @"^Document (\d+), *(.+) owned by (.+) was printed on
(.*) via port IP_(\d{1,3}\.\d {1,3}\.\d{1,3}\ .\d{1,3})\. Size in bytes:
(\d+); pages printed: (\d+)";
Regex re = new Regex(strMatch) ;
Match m = re.Match(strTex t);
if(m.Success)
{
PrintDocNum = m.Groups[1].ToString();
PrintDocName = m.Groups[2].ToString();
PrintUser = m.Groups[3].ToString();
PrintServerName = m.Groups[4].ToString();
PrintIp = m.Groups[5].ToString();
PrintByte = m.Groups[6].ToString();
PrintPages = m.Groups[7].ToString();
OleDbConnection conn = new OleDbConnection ();
// TODO: Modify the connection string and include any
// additional required properties for database.
conn.Connection String = @"Provider=Micr osoft.Jet.OLEDB .4.0;" +
@"Data source= E:\April30\Db\T estDb.mdb" ;
conn.Open();
string sqlInsert=@"ins ert into
TestTable(DocNu m,DocName,User, ServerName,Byte ,Ip,Pages) values
(@PrintDocNum,@ PrintDocName,@P rintUser,@Print ServerName,@Pri ntByte,@PrintIp ,@PrintPages)";
OleDbCommand cmd1=new OleDbCommand(sq lInsert,conn);
cmd1.Parameters .Add("@PrintDoc Num",System.Dat a.OleDb.OleDbTy pe.VarChar,50,P rintDocNum);

cmd1.Parameters .Add("@PrintDoc Name",System.Da ta.OleDb.OleDbT ype.VarChar,50, PrintDocName);
cmd1.Parameters .Add("@PrintUse r",System.Data. OleDb.OleDbType .VarChar,50,Pri ntUser);
cmd1.Parameters .Add("@PrintSer verName",System .Data.OleDb.Ole DbType.VarChar, 50,PrintServerN ame);
cmd1.Parameters .Add("@PrintByt e",System.Data. OleDb.OleDbType .VarChar,50,Pri ntByte);
cmd1.Parameters .Add("@PrintIp" ,System.Data.Ol eDb.OleDbType.V arChar,50,Print Ip);
cmd1.Parameters .Add("@PrintPag es",System.Data .OleDb.OleDbTyp e.VarChar,50,Pr intPages);
//Console.WriteLi ne("Command Created");
cmd1.ExecuteNon Query();//insert string
//Console.WriteLi ne("insert end");
conn.Close();
}

}
}
}


Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
6546
by: Dave | last post by:
After following Microsofts admonition to reformat my system before doing a final compilation of my app I got many warnings/errors upon compiling an rtf file created in word. I used the Help Workshop program: hcw.exe that's included with Visual Basic. This exact same file compiled perfectly with no notes, warnings or errors prior to reformatting my system. Prior to the reformatting, I copied the help.rtf file onto a CD and checked the box to...
9
4401
by: Tom | last post by:
A question for gui application programmers. . . I 've got some GUI programs, written in Python/wxPython, and I've got a help button and a help menu item. Also, I've got a compiled file made with the microsoft HTML workshop utility, lets call it c:\path\help.chm. My question is how do you launch it from the GUI? What logic do I put behind the "help" button, in other words. I thought it would be os.spawnv(os.P_DETACH,...
0
2208
by: python-help-bounces | last post by:
Your message for python-help@python.org, the Python programming language assistance line, has been received and is being delivered. This automated response is sent to those of you new to python-help, to point out a few resources that can help with answering your own questions, or improve the chances of getting a useful answer from the helpers. The most comprehensive overview of python.org help resources is at ...
4
3349
by: Sarir Khamsi | last post by:
Is there a way to get help the way you get it from the Python interpreter (eg, 'help(dir)' gives help on the 'dir' command) in the module cmd.Cmd? I know how to add commands and help text to cmd.Cmd but I would also like to get the man-page-like help for classes and functions. Does anyone know how to do that? Thanks. Sarir
6
3016
by: d.warnermurray | last post by:
I am doing a project for school that involves creating help files for a html authoring tool. If you could help me with answers to some questions it would really help. 1. What tasks do you expect an html authoring tool to help you accomplish? 2. What do you expect from online help for a html authoring tool? 3. What audience do you think a freeware html authoring tool is directed towards?
2
3940
by: BT Openworld | last post by:
I have just had to upgrade to Access 2003 as Access 97 EMail (SendObject) doesn't work when loaded on Windows XP. I'm finding my way around Access 2003 but my biggest problem is getting information. When I bought Access 1.0 many years ago, I got a paper manual and an excellent help file with all you needed to know. With Access 97 the manual came as a 'Building Applications' document on the CD and I still had the excellent help. With Access...
9
2246
by: JJ | last post by:
Do you all use HTML help workshop to create your help system. I am finding it quite clumsy to use. Mayeb because I am not used to using it. Do any of you use any other techniques to create help for your progs? Whats the current popular approach to creating help? I am only wanting a straight help file accessible from a menu - no context sensitive stuff. TIA
8
3226
by: Mark | last post by:
I have loaded Visual Studio .net on my home computer and my laptop, but my home computer has an abbreviated help screen not 2% of the help on my laptop. All the settings look the same on both including search the internet for help, but the help is worthless. Any ideas?
3
2027
by: lord.zoltar | last post by:
I've managed to get a nice little chm help system written. Now I need to display it! I added a HelpProvider to my MDIParent form and set the namespace of the HelpProvider to be the help file. So far so good - when I press F1, I get HTML Help popping up with my Help file. This is good but I've been requested to make Help pop up when the user clicks on "Help" in the menu, or on a specific Help Button. I'm trying to trigger the HelpRequested...
1
6127
by: trunxnirvana007 | last post by:
'UPGRADE_WARNING: Array has a new behavior. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="9B7D5ADD-D8FE-4819-A36C-6DEDAF088CC7"' 'UPGRADE_WARNING: Couldn't resolve default property of object Label. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"' Label = New Object(){Box1, Box2, Box3, Box4, Box5, Box6, Box7, Box8, Box9, Box10, Box11,...
0
8603
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9157
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8895
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6518
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4369
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2329
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.