473,545 Members | 2,444 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 1435
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
6497
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...
9
4386
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...
0
2187
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...
4
3330
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
2994
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...
2
3932
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...
9
2234
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...
8
3208
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
2020
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...
1
6114
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:...
0
7490
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7425
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...
0
7935
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7780
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6009
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3465
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1911
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1037
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
734
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...

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.