|
|
Hi,
I am new to Web service. Using ASMX web service, the live data from the database can be shown in Xcelius Dashboard. Sample helloworld.asmx as below used to show "Hello World" in xcelsius dashboard. Xcelsius only support asmx.
<%@ WebService Language="C#"
Class="ProgWS.Ch02.HelloWorldService" %>
using System.Web.Services;
namespace ProgWS.Ch02
{
public class HelloWorldService: WebService
{
[WebMethod]
public string HelloWorld()
{
return "Hello World";
}
}
}
I have tried by combining code from www.jonasjohn.de/snippets/csharp/sql-connection-example.htm with above code, I am not succeed.
I would appreciate if you could let me know the sample ASMX C# program to connect SQL Server and return data from a table (adventureworks.Person.Contact.FirstName).
Thanks.
modified on Monday, July 19, 2010 10:38 AM
|
|
|
|
|
You connect to SQL Server the same you normally do, wrapping it in a Web Service doesn't change anything.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Thanks for the quick reply, Mark. I have updated as per the "How to get an answer to your question" #7.
I have tried Helloworld.asmx, works fine. I can use the results in xcelsius.
<pre>
<%@ WebService Language="C#"
Class="ProgWS.Ch02.HelloWorldService" %>
using System.Web.Services;
namespace ProgWS.Ch02
{
public class HelloWorldService: WebService
{
[WebMethod]
public string HelloWorld()
{
return "Hello World";
}
}
}
</pre>
I have tried the below code and got the "This web service does not conform to WS-I Basic Profile v1.1." error.
<pre>
<%@ WebService Language="C#"
Class="csbook.ch15.Example15_3" %>
using System.Web.Services;
using System;
using System.Data;
using System.Data.SqlClient;
namespace csbook.ch15 {
class Example15_3 {
static void Main(string[] args) {
// create an open the connection
SqlConnection conn =
new SqlConnection("Data Source=philshiv;"
+ "Initial Catalog=AdventureWorks;"
+ "User ID=sa;Password=changeme");
conn.Open();
// create a SqlCommand object for this connection
SqlCommand command = conn.CreateCommand();
command.CommandText = "Select * from Person.Contact";
command.CommandType = CommandType.Text;
// execute the command that returns a SqlDataReader
SqlDataReader reader = command.ExecuteReader();
// display the results
while (reader.Read()) {
string output = reader["CompanyName"].ToString();
Console.WriteLine(output);
}
// close the connection
reader.Close();
conn.Close();
}
}
}
</pre>
Thanks for your time. Could you please help me to resolve the issue.
Thanks
modified on Monday, July 19, 2010 3:45 PM
|
|
|
|
|
|
Thanks for the quick reply, Mark. I have updated as per the "How to get an answer to your question" #7.
I have tried Helloworld.asmx, works fine. I can use the results in xcelsius.
<pre>
<%@ WebService Language="C#"
Class="ProgWS.Ch02.HelloWorldService" %>
using System.Web.Services;
namespace ProgWS.Ch02
{
public class HelloWorldService: WebService
{
[WebMethod]
public string HelloWorld()
{
return "Hello World";
}
}
}
</pre>
I have tried the below code and got the "This web service does not conform to WS-I Basic Profile v1.1." error.
<pre>
<%@ WebService Language="C#"
Class="csbook.ch15.Example15_3" %>
using System.Web.Services;
using System;
using System.Data;
using System.Data.SqlClient;
namespace csbook.ch15 {
class Example15_3 {
static void Main(string[] args) {
// create an open the connection
SqlConnection conn =
new SqlConnection("Data Source=philshiv;"
+ "Initial Catalog=AdventureWorks;"
+ "User ID=sa;Password=changeme");
conn.Open();
// create a SqlCommand object for this connection
SqlCommand command = conn.CreateCommand();
command.CommandText = "Select * from Person.Contact";
command.CommandType = CommandType.Text;
// execute the command that returns a SqlDataReader
SqlDataReader reader = command.ExecuteReader();
// display the results
while (reader.Read()) {
string output = reader["CompanyName"].ToString();
Console.WriteLine(output);
}
// close the connection
reader.Close();
conn.Close();
}
}
}
</pre>
Thanks for your time. Could you please help me to resolve the issue.
Thanks
|
|
|
|
|
|
|
Ennis Ray Lynch, Jr. wrote: Bing? Really?
it's just an acronym; he meant to say: Blimey I Need Google
|
|
|
|
|
|
|
Hi,
Actually I made a user control that its interface is like "glass windows" in windows vista and seven.
My pattern was this picture[^]
using "Photoshop" and draw every layer with C# and .Net drawing classes, I finally draw it.
In first step, i create a bitmap class and then each layer will be drawn on it using graphic path and brushes and so on.
here is the control.glass panel[^]
(you must first add the "reflect.png" file to your project resources and then add class to project then build, ...)
OK,
my problem is the low efficiency of this control while moving and resizing parent form.
because this works, cause calling "draw" method of the control and when calling of method got a lot, it will be slow down the application and more important, it is very CPU hungry.
I want you to learn me a way to draw the user interface of this control
1-using dot net 2.0
2-efficient, like other windows controls.
is there a way to paint UI using directx,...?(I mean not WPF)
if there is no way, i will remove the reflect part of the code that causes high CPU using.
thank you.
modified on Monday, July 19, 2010 8:32 AM
|
|
|
|
|
Hi,
Most of our readers don't download archives to browse code, you'd get more replies if you'd add the code to the post (using PRE tags) I've included a small snippet of your code below for reference;
public void draw()
{
if (Width < 20 || Height < 20)
{
return;
}
Bitmap b = new Bitmap(Width, Height);
Graphics gr = Graphics.FromImage(b);
GraphicsPath gp=new GraphicsPath();
LinearGradientBrush br;
gr.SmoothingMode = SmoothingMode.HighSpeed;
for (int i = 0; i < 10; i++)
{
gp = DrawRoundRect(i, i, Width - i * 2 - 1, Height - i * 2 - 1, 7);
br = new LinearGradientBrush(Bounds, Color.FromArgb(i * 3, Color.Black),
Color.FromArgb(i * 3, Color.Black), LinearGradientMode.Vertical);
gr.DrawPath(new Pen(br, 4), gp);
br.Dispose();
}
On to your question; you're drawing in a dedicated method, called draw . This builds a bitmap in turn, and setting that as a backgroundimage.
You can paint directly on the canvas by overriding the Paint-handler;
protected override void OnPaint(PaintEventArgs e)
{
Graphics g = e.Graphics;
} You can then use the Graphics object to draw directly to the canvas of the control.
Next, if your control needs redrawing, don't call the draw method, but call the Invalidate [^] method. Third tip would be to re-using objects like brushes and pens, as opposed to creating new ones each time you have to draw.
Hope this helps
I are Troll
|
|
|
|
|
thanks eddy.(i don't forget your recommendation about source code
i think i already done this. but the program crashed down.
because the paint event consecutive raise.
i will test it again and will report you.
thanks again.
(what about GPU, ...?)
i forgot it:
i want when the form moves, the control paint itself to draw reflect on the glass panel.
when you move form, you will see that the reflect is stable
modified on Monday, July 19, 2010 9:09 AM
|
|
|
|
|
mohammad_b wrote: because the paint event consecutive raise.
The method is called by Windows when it needs to repaint a part of the form. If you post your new paint-handler, we'll look at it
mohammad_b wrote: (what about GPU, ...?)
I'd recommend converting to WPF over trying to directly access the GPU. You could even create your own effects[^].
mohammad_b wrote: i want when the form moves, the control paint itself to draw reflect on the glass panel.when you move form, you will see that the reflect is stable
Yup, your life would be easier using WPF. Using WinForms, you'd have to Invalidate the control to force a repaint. I don't know how this will perform with a large area if you call this method in the OnMouseMove event. You'd have to give it a try to find out.
I are Troll
|
|
|
|
|
thanks again.
first i apologize for my dirty and ugly coding.
when i reopen the class codes and look at it, I ashamed from myself that what is this code that i written.
----
the paint method is good. i switched to it.
I remove all codes and just a simple border drawing code and glow shadow with a new and efficient method is remained.
it still is beautiful
----
now i can't switch to WPF. but it is in my learning progs
bye
|
|
|
|
|
mohammad_b wrote: thanks again.first i apologize for my dirty and ugly coding.
With pleasure, and don't apologize; your approach is logical if you haven't had to write a paint-handler before. A good effort, and a nice read.
My compliments on solving the issue
I are Troll
|
|
|
|
|
Hi ,
Inorder to get the shortname in vb.net I have written the following code .but it is returning null .Can you please help
Private Declare Function GetShortPathName Lib "kernel32" Alias "GetShortPathNameA" (ByVal longPath As String, ByVal shortPath As String, ByVal shortBufferSize As Int32) As Int32
Dim longPathName As String
longPathName = dest
Dim longPathLength As Int32 = longPathName.Length
Dim shortPathName As String = Space(longPathLength)
Dim returnValue As Int32
returnValue = GetShortPathName(longPathName, shortPathName,longPathLength)
MsgBox(shortPathName.ToString)
|
|
|
|
|
Try this one.
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
public static extern int GetShortPathName(
[MarshalAs(UnmanagedType.LPTStr)]
string path,
[MarshalAs(UnmanagedType.LPTStr)]
StringBuilder shortPath,
int shortPathLength
);
public static void Main()
{
StringBuilder shortPath = new StringBuilder(255);
GetShortPathName(@"D:\My Temp\ResourseProvider\sql.txt", shortPath, shortPath.Capacity);
Console.WriteLine(shortPath.ToString());
}
HTH
Jinal Desai - LIVE
Experience is mother of sage....
|
|
|
|
|
thanks 4 ur support
, but very sorry .Can you please give the code in VB.Net.
|
|
|
|
|
Please do not repost the same question.
You have already posted your question here[^] and got attention.
Please go through the forum posting guidelines[^].
And the code I have posted is in CSharp. So now you need to take
effort in just converting syntax buddy. So, from next time please
put some effort before posting anything on this forum.
Private Declare Auto Function GetShortPathName Lib "kernel32" ( _
ByVal lpszLongPath As String, _
ByVal lpszShortPath As StringBuilder, _
ByVal cchBuffer As Integer) As Integer
Public Function GetShortPath(ByVal longPath As String) As String
Dim requiredSize As Integer = GetShortPathName(longPath, Nothing, 0)
Dim buffer As New StringBuilder(requiredSize)
GetShortPathName(longPath, buffer, buffer.Capacity)
Return buffer.ToString()
End Function
HTH
Jinal Desai - LIVE
Experience is mother of sage....
|
|
|
|
|
Bit harsh there.
I agree he should have stuck to the original thread (but he is new here), but that aside, he did try to convert your code to VB.Net, just not very succesfully. You posting (or should I say re-posting) in C# when you can see his question is in VB.Net is just as unhelpful. Some of us are code bi-lingual, but not everyone is.
We should be encouraging people to post better, not discouraging them from posting at all.
|
|
|
|
|
Ok, buddy.
I will keep in mind from next time.
HTH
Jinal Desai - LIVE
Experience is mother of sage....
|
|
|
|
|
How to change the name of the datagrid column thru programs?
For example.
in the table pmast, rcpno is the name of a field. But in the datagrid, I want to display the column heading as Receipt No.
The code is as follows :
Private Sub viewbtn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles viewbtn.Click
Dim strconv As New OleDb.OleDbConnection(ds)
disallbtn()
binddv = New OleDb.OleDbDataAdapter("select rcpno, rcpdt ,pname from pmast order by rcpno", strconv)
If Not oledv.Tables("pmast") Is Nothing Then
oledv.Tables("pmast").Clear()
End If
binddv.Fill(oledv, "pmast")
DataGridView1.DataSource = oledv.Tables("pmast")
DataGridView1.Show()
DataGridView1.Focus()
End Sub
|
|
|
|
|
Try this -
Dim myStyle As New DataGridTextBoxColumn
myStyle.MappingName = "Emp_name"
myStyle.HeaderText = "Employee Name"
|
|
|
|
|