473,467 Members | 1,985 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Connection

27 New Member
Hi,

I need to insert the entries of the log file into a database table..
I have made a stored procedure but there is some problem .............I am unable to rectify that.........

SqlConnection con=new SqlConnection("Data Source=***********;Initial Catalog=WebServicesLogFiles;User Id=sa;Password=sa;");
con.Open();
SqlCommand com=new SqlCommand("usp_addlogintotable",con);
com.Parameters.Add(new SqlParameter("@LogDateTime",SqlDbType.DateTime,0," LogDateTime"));
com.Parameters.Add(new SqlParameter("@MethodName",SqlDbType.VarChar,50,"M ethodName"));
com.Parameters.Add(new SqlParameter("@Status",SqlDbType.Int,0,"Status"));
com.Parameters.Add(new SqlParameter("@Message",SqlDbType.VarChar,100,"Mes sage"));
com.CommandType=CommandType.StoredProcedure;
// com.Prepare();
com.ExecuteNonQuery();
con.Close();
Jan 30 '07 #1
5 1418
enreil
86 New Member
What sort of error do you get? Are you able to connect to your database at all, or is there an issue with your stored procedure?
Jan 30 '07 #2
kbipul
27 New Member
What sort of error do you get? Are you able to connect to your database at all, or is there an issue with your stored procedure?

Hi, i am getting the error

"Procedure 'usp_addlogintotable' expects parameter '@LogDateTime', which was not supplied."
Jan 31 '07 #3
kenobewan
4,871 Recognized Expert Specialist
Welcome to the pain of working with dates in databases. If you remove this field and test does it work? Look at your database field design and then test using format change. For uploading dates to db I find that datetime.parseexact tends to work best. Here is an example that may help:
How to convert user input in dMy format to Mdy?
Jan 31 '07 #4
kbipul
27 New Member
Welcome to the pain of working with dates in databases. If you remove this field and test does it work? Look at your database field design and then test using format change. For uploading dates to db I find that datetime.parseexact tends to work best. Here is an example that may help:
How to convert user input in dMy format to Mdy?

Ya I tried after removing the datetime field.But still I could not get the desired result.The same problem continues for the other field after removing the datetime field..
and the example that you sent to me is not very clear to me...May be I am not that well versed to get it.........
Feb 1 '07 #5
kbipul
27 New Member
Ya I tried after removing the datetime field.But still I could not get the desired result.The same problem continues for the other field after removing the datetime field..
and the example that you sent to me is not very clear to me...May be I am not that well versed to get it.........
Hi,

I have got the solution through a friend..................



SqlParameter objpara = new SqlParameter();

// For datetime

objpara = new SqlParameter("@LogDateTime",SqlDbType.DateTime);

objpara.Value = DateTime.Now;

com.Parameters.Add(objpara);



this type of objects were required to locate the types of the entries
Feb 1 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: G-Fit | last post by:
Hello group, I have several servers hosting SQL databases. On each of them, I have several databases. All those databases have the same structure (even those on different servers), only the data...
11
by: pradeep_TP | last post by:
Hi all, I have a few questions that I have been wanting to ask for long. These are all related to ADO.net and specifically to conenction to database. 1) If I have opened a connection to a...
6
by: Chris Szabo | last post by:
I've created a data access layer for a .NET web application. I'm using C# and framework 1.1. I'm getting an error from time to time when I close a connection saying: ...
18
by: Rob Nicholson | last post by:
We're getting an occasional occurrence of the following error when two users try and open the same record in our ASP.NET app: "There is already an open DataReader associated with this Connection...
35
by: Eric Sabine | last post by:
In my Finally block, I was using cn.close (where cn is an ADO.NET connection object, SQLConnection to be exact) and then I came across the following in some microsoft code. If Not cn Is Nothing...
3
by: Martin B | last post by:
Hallo! I'm working with C# .NET 2.0, implementing Client/Server Applications which are connecting via Network to SQL-Server or Oracle Databases. To stay independent from the underlaying Database...
20
by: fniles | last post by:
I am using VS2003 and connecting to MS Access database. When using a connection pooling (every time I open the OLEDBCONNECTION I use the exact matching connection string), 1. how can I know how...
3
by: fniles | last post by:
In the Windows application (using VB.NET 2005) I use connection pooling like the following: In the main form load I open a connection using a connection string that I stored in a global variable...
0
by: Robert Avery | last post by:
In VBA/VB6, I had a class (incomplete sample below) that watched and displayed for the user all connection events, so that I could easily see what SQL was taking a long time, and when it freezes, I...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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,...
1
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...
0
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...
0
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...
0
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 ...

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.