Hello all, i have some questions as to the best way to accomplish what I am trying to do.
I am creating a form that id like to have post data to tables in DB that I have a a SQL 2008 server. The form is being created in ADobe Live Cycle Desigher and has an option of linking to a wdsl file/ url. Id like to find a way to creat a web service to
post the data to my tables. I have been searching around and reading a lot but most of the examples i see of web services just access stored procedures. Id like to just submit the data to some tables and perhaps provide some feedback that the data was submitted.
If you have a demo or some exmples it would be great.
So I am getting closer to getting things the way I need. This has been a good start from a lot of examples on the web one issue with the current code is I can only submit data to one table but the form I am creating has data that needs to go to different
tables.
Bellow is my code:
[WebMethod]
public void AddClass(string strUserID, string strAccountNumber)
{
string connStr = ConfigurationManager.ConnectionStrings["con1"].ConnectionString;
string cmdText = string.Empty;
using (SqlConnection sqlConn = new SqlConnection(connStr))
{
cmdText = "INSERT INTO TimeEntry(UserID,AccountNumber) VALUES(@USERID,@ACCOUNTNUMBER)";
SqlCommand insertComm = new SqlCommand(cmdText);
insertComm.Connection = sqlConn;
SqlParameter[] sp = new SqlParameter[2];
sp[0] = new SqlParameter("@USERID", SqlDbType.VarChar, 9);
sp[1] = new SqlParameter("@ACCOUNTNUMBER", SqlDbType.VarChar, 12);
sp[0].Value = strUserID;
sp[1].Value = strAccountNumber;
insertComm.Parameters.AddRange(sp);
if (sqlConn.State == ConnectionState.Closed)
{
sqlConn.Open();
}
insertComm.ExecuteNonQuery();
}
}
So reading through a lot of this over the weekend. I think I want to go with the linq to sql but not sure how the code should look. I am verry new to all of this.
One question I have has to do with the form I am creating in Acrobat, it is a time sheet and has a table with spots to enter time for the week. But each time data should go to the same tables and fields in the DB just as seperate rows. The link below is
an example. each days time should go to the same table just with a different date and amount of time.
Basicly I have a sheet that is a service report/time card, here is a screenshot of the actual form. http://imgur.com/o4hny
What I want to do is have the service report write to ItemEnrty, TimeEntry, and JDEWorkOrder from the Service report.
If I understand the concepts of linq to sql correctly I should be able to make an entity called servicereport or something smilar which would have the association of the three tables and add the appropriate information.
The main information I need from the form is descriped bellow.
TimeEntry
UserID
WorkDate
AccountNumber
BeginTime
EndTime
Units (this is begin time - end time to figure # of hours. I was thinking I could just do this in the form)
PayType
BuisnessUnit
ItemEntry
UserID
IssueDate
AccountNumber
Item
Units (not same as units from TimeEntry, this is qty of item)
JDEWorkOrder
Order# (WO# field on form)
Description (Description field on form)
Ok, the more and more I think about this I am wondering , why I need any type of relation between these tables, because I dont really have a real need and it appears to be really confusing me ! Whats
the simplest way to just have my service update the 3 tables i need?
jcervantes
Member
34 Points
20 Posts
Post to Web Service DB from PDF
Oct 27, 2011 11:38 PM|LINK
Hello all, i have some questions as to the best way to accomplish what I am trying to do.
I am creating a form that id like to have post data to tables in DB that I have a a SQL 2008 server. The form is being created in ADobe Live Cycle Desigher and has an option of linking to a wdsl file/ url. Id like to find a way to creat a web service to post the data to my tables. I have been searching around and reading a lot but most of the examples i see of web services just access stored procedures. Id like to just submit the data to some tables and perhaps provide some feedback that the data was submitted. If you have a demo or some exmples it would be great.
Thanks!
service web sql
jcervantes
Member
34 Points
20 Posts
Re: Post to Web Service DB from PDF
Oct 28, 2011 07:41 PM|LINK
So I am getting closer to getting things the way I need. This has been a good start from a lot of examples on the web one issue with the current code is I can only submit data to one table but the form I am creating has data that needs to go to different tables.
Bellow is my code:
[WebMethod] public void AddClass(string strUserID, string strAccountNumber) { string connStr = ConfigurationManager.ConnectionStrings["con1"].ConnectionString; string cmdText = string.Empty; using (SqlConnection sqlConn = new SqlConnection(connStr)) { cmdText = "INSERT INTO TimeEntry(UserID,AccountNumber) VALUES(@USERID,@ACCOUNTNUMBER)"; SqlCommand insertComm = new SqlCommand(cmdText); insertComm.Connection = sqlConn; SqlParameter[] sp = new SqlParameter[2]; sp[0] = new SqlParameter("@USERID", SqlDbType.VarChar, 9); sp[1] = new SqlParameter("@ACCOUNTNUMBER", SqlDbType.VarChar, 12); sp[0].Value = strUserID; sp[1].Value = strAccountNumber; insertComm.Parameters.AddRange(sp); if (sqlConn.State == ConnectionState.Closed) { sqlConn.Open(); } insertComm.ExecuteNonQuery(); } }service web sql
kushalrdalal
Contributor
7128 Points
1270 Posts
Re: Post to Web Service DB from PDF
Oct 28, 2011 07:49 PM|LINK
You can create stored procedure or even write multiple queries.
Check this link for the same -
http://social.msdn.microsoft.com/Forums/en-US/sqlgetstarted/thread/77ce4b34-581b-47c8-aad6-96910ecd8ab5/
http://forums.asp.net/p/1098258/1664138.aspx/1?Re+SQL+Insert+to+multiple+tables
http://weblogs.asp.net/scottgu/archive/2007/07/11/linq-to-sql-part-4-updating-our-database.aspx
service web sql
My Blog
LinkedIn Profile
jcervantes
Member
34 Points
20 Posts
Re: Post to Web Service DB from PDF
Oct 31, 2011 01:54 PM|LINK
So reading through a lot of this over the weekend. I think I want to go with the linq to sql but not sure how the code should look. I am verry new to all of this.
One question I have has to do with the form I am creating in Acrobat, it is a time sheet and has a table with spots to enter time for the week. But each time data should go to the same tables and fields in the DB just as seperate rows. The link below is an example. each days time should go to the same table just with a different date and amount of time.
http://images.vertex42.com/ExcelTemplates/timesheet-large.gif
What do you think?
kushalrdalal
Contributor
7128 Points
1270 Posts
Re: Post to Web Service DB from PDF
Oct 31, 2011 02:04 PM|LINK
You can do that with out any issue.
Once the sheet is filled you can insert the data to table and in separate row by looping thru the sheet.
If you need further help then let us know your table structure.
My Blog
LinkedIn Profile
jcervantes
Member
34 Points
20 Posts
Re: Post to Web Service DB from PDF
Oct 31, 2011 03:20 PM|LINK
The table structure is shown here http://imgur.com/lSxJn
Basicly I have a sheet that is a service report/time card, here is a screenshot of the actual form. http://imgur.com/o4hny
What I want to do is have the service report write to ItemEnrty, TimeEntry, and JDEWorkOrder from the Service report.
If I understand the concepts of linq to sql correctly I should be able to make an entity called servicereport or something smilar which would have the association of the three tables and add the appropriate information.
The main information I need from the form is descriped bellow.
TimeEntry
UserID
WorkDate
AccountNumber
BeginTime
EndTime
Units (this is begin time - end time to figure # of hours. I was thinking I could just do this in the form)
PayType
BuisnessUnit
ItemEntry
UserID
IssueDate
AccountNumber
Item
Units (not same as units from TimeEntry, this is qty of item)
JDEWorkOrder
Order# (WO# field on form)
Description (Description field on form)
What do you think? Am I in over my head?!? :)
kushalrdalal
Contributor
7128 Points
1270 Posts
Re: Post to Web Service DB from PDF
Oct 31, 2011 03:24 PM|LINK
Check this links for how to insert data into sql table with linq. You have to create classes or class as per your requirement.
http://www.hookedonlinq.com/LINQtoSQL5MinuteOverview.ashx
http://csainty.blogspot.com/2008/01/linq-to-sql-insertupdatedelete.html
</div>
My Blog
LinkedIn Profile
jcervantes
Member
34 Points
20 Posts
Re: Post to Web Service DB from PDF
Oct 31, 2011 05:07 PM|LINK
Ok, the more and more I think about this I am wondering , why I need any type of relation between these tables, because I dont really have a real need and it appears to be really confusing me !
Whats
the simplest way to just have my service update the 3 tables i need?
kushalrdalal
Contributor
7128 Points
1270 Posts
Re: Post to Web Service DB from PDF
Oct 31, 2011 06:03 PM|LINK
It is not necessary to have relationship.
You can have your table structure as per your requirement.
http://www.asp.net/mvc/tutorials/creating-model-classes-with-linq-to-sql-vb
My Blog
LinkedIn Profile
jcervantes
Member
34 Points
20 Posts
Re: Post to Web Service DB from PDF
Oct 31, 2011 07:00 PM|LINK
Ok, I am attempting to apply the tuturial to my curent web service project but I dont have a folder "models" any idea why?