|
I need this as an example for my new server and I really don't know how to do this in VB ... if you can help me someone
c# is here:
http://www.another-search.com/search-api/c-sharp-dot-net
|
|
|
|
|
Strip out the comments and summaries and your left with just a few lines
namespace XML_Dataset
{
public partial class Form1 : Form
{
private searchTable testSearchTable = new searchTable();
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
this.dataGridView1.DataSource = this.testSearchTable.Tables["search"];
}
private void getDataFromAS_Click(object sender, EventArgs e)
{
this.testSearchTable.Clear();
this.testSearchTable.ReadXml(this.testXMLStringAddr.Text);
}
private void generateDatasetToFile_Click(object sender, EventArgs e)
{
System.IO.StreamWriter xmlSW = new System.IO.StreamWriter("testSearchTable.xml");
this.testSearchTable.WriteXml(xmlSW, XmlWriteMode.WriteSchema);
xmlSW.Close();
MessageBox.Show("XML Schema was generatoted to the file: testSearchTable.xml");
}
}
}
Have a look at MSDN for each statement and you'll find examples for both C# and VB, if not - GOOGLE!
You'll need to have the code or dll for the searchTable class that's referenced near the top.
Dave
|
|
|
|
|
(I used Instant VB, but any converter would have been able to handle this)
Namespace XML_Dataset
Partial Public Class Form1
Inherits Form
Private testSearchTable As New searchTable()
Public Sub New()
InitializeComponent()
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)
Me.dataGridView1.DataSource = Me.testSearchTable.Tables("search")
End Sub
Private Sub getDataFromAS_Click(ByVal sender As Object, ByVal e As EventArgs)
Me.testSearchTable.Clear()
Me.testSearchTable.ReadXml(Me.testXMLStringAddr.Text)
End Sub
Private Sub generateDatasetToFile_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim xmlSW As New System.IO.StreamWriter("testSearchTable.xml")
Me.testSearchTable.WriteXml(xmlSW, XmlWriteMode.WriteSchema)
xmlSW.Close()
MessageBox.Show("XML Schema was generatoted to the file: testSearchTable.xml")
End Sub
End Class
End Namespace
David Anton
http://www.tangiblesoftwaresolutions.com
C++ to C# Converter
C++ to VB Converter
C++ to Java Converter
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: convert VB or C# to C++/CLI
Java to VB & C# Converter: convert Java to VB or C#
|
|
|
|
|
I have a windows application that sends out an email to a person when it reaches the necessarry point. Inside the email there is a link to the application, when the user clicks this the application opens. My problem is I need to be able to send this application an argument on startup so when the user clicks this link the application will open, parse the argument and show the appropriate record (this is based on the argument sent). Does anyone know if this is possible. Thanks for you help.
Thanks
Matt
|
|
|
|
|
Hi,
I need to write some log info out of my app and into a text file.
I might not be doing this the right way so let me know if im not, basically I want to write to a text file but when I deploy the package I want the text file to write to the location of the app ie like (c:/program files/my application/log).
I added a text file to resources.resx called Log.txt.
Ive set the properties(build action) of the text file as content as i want to be able to access this data.
how do i write to this file?
i got something like this but it dont work
FileInfo fi = new FileInfo(Properties.Resources.Elog);
if (fi.Exists.Equals(true))
{
ResourceManager rm = new ResourceManager();
FileStream fsWrite = new FileStream(Properties.Resources.Elog, FileMode.Append);
StreamWriter sw = new StreamWriter(fsWrite);
sw.WriteLine(DateTime.Now + ":" + xInternalError);
sw.Close();
}
|
|
|
|
|
Is "fi.Exists" always coming back as false? Why not do the following:
using (FileStream fs = new FileStream("Log.txt", FileMode.Append, FileAccess.Write, FileShare.None) {
StreamWriter sw = new StreamWriter(fs);
sw.WriteLine(...);
sw.Close();
} Won't Log.txt then appear in your application directory?
Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|
|
Hey, yeah it never works its always false.
I suppose what im getting at is that when I come to deploy/install the application I wont no the location to write the log file to, I mean there is some-way obviosuly, but I dont know how to do it myself.
all I want to do is say ok where ever this user installs the application I want a folder where the exe is located ie
c:/program files/myApp/app.exe
then create a folder
c:/program files/myApp/Log/
and write a log file log.txt to that folder.
I think im making a pigs ear out of this, guidance and examples are greatly welcomed.
|
|
|
|
|
Application.StartupPath will give you the folder path where the executable is present.
I suggest you to use Application.UserAppDataPath as it will provide the application data folder of the user and will be user specific.
*jaans
|
|
|
|
|
IIRC, embedded resources are read-only and you wont be able to write anything to it.
*jaans
|
|
|
|
|
|
Hi,
I am searching for some well-organized training materials that I could use to learn C# fairly rapidly. The AppDev stuff looks good, but is real expensive bought new. If anybody has any courses that they have used and found valuable that they would be willing to sell, please contact me!
Thanks to all.
John
|
|
|
|
|
Try this[^] site. It has a good reputation, and is reasonably priced.
|
|
|
|
|
Hi Pete,
Thanks for the reply. Yeah, I saw this site and have been looking it over, but their C# stuff seems a little dated, focusing on Visual Studio 2003. I have 2005 and it may not be that much of a difference. In any event, this seems to a good starting point.
|
|
|
|
|
They do cover 2005 stuff (e.g. this[^]).
|
|
|
|
|
Cool! Thanks.
Just a question pertaining to Visual Studio 2003 (which I don't have). Do you think that the 2003 courses would be applicable to 2005?
|
|
|
|
|
They won't hurt (in the main). Some things have been superseded (e.g. don't use CollectionBase for lists, use generic lists instead), but the general principals are the same.
|
|
|
|
|
|
Hi All,
I have a xml file and i wana create a xsd file through code.
I don't know how can i do it , i know only how to create xsd file via VS .
If anyone knows pls help me.
Thanks.
Praveen Sharma
|
|
|
|
|
There is a tool[^] (Xsd.exe) from Microsoft, which performs tasks like that.
SkyWalker
|
|
|
|
|
Hai all,
I am getting error in while access the webService values in C#ASP.NET form.
My Code is
WEBSERVICE: Name(localhost\TestWebService\firstService.asmx)
----------
public struct structClientData
{
public string Name;
public int ID;
}
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class firstService : System.Web.Services.WebService
{
[WebMethod]
public string HelloWorld() {
return "Hello World";
}
[WebMethod(Description = "Get the client Name and ID")]
public structClientData[] GetClientInfo(int Number)
{
structClientData[] objClientDatas = null;
if (Number > 0 && Number <= 10)
{
objClientDatas = new structClientData[Number];
for (int i = 0; i < Number; i++)
{
objClientDatas[i].Name = "Clinet" + Number.ToString();
objClientDatas[i].ID = Number;
}
}
return objClientDatas;
}
}
I want display that web service return all values on Default.aspx Page.
My error ASPX code is:
Button1_Click()
{
firstService obj1Service =new firstService();
try
{
string[] str=obj1Service.GetClientInfo(int.Parse(TextBox1.Text));
[fill up remaining code] or [your suggession code]
}
catch
{
}
}
Error is :
----------
Cannot implicitly convert type 'localhost.structClientData[]' to string[]'
advance Thanks a lot.
Thanks and Regards
TamizhMS
|
|
|
|
|
Tamizh wrote: string[] str=obj1Service.GetClientInfo(int.Parse(TextBox1.Text));
This is your problem. The method is returning an array of structClientData, but you are trying to put it into a string array. Try changing this to :
structClientData[] str=obj1Service.GetClientInfo(int.Parse(TextBox1.Text)); Please change the name of your textbox - don't rely on default control names.
|
|
|
|
|
I didnt know you have mentioned "structClientData[]" What data type its?
structClientData[] str=obj1Service.GetClientInfo(int.Parse(TextBox1.Text));
This my Web service code:
-------------------------
using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
public struct structClientData
{
public string Name;
public int ID;
}
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class firstService : System.Web.Services.WebService
{
public firstService () {
//Uncomment the following line if using designed components
//InitializeComponent();
}
[WebMethod]
public string HelloWorld() {
return "Hello World";
}
[WebMethod(Description = "Get the client Name and ID")]
public structClientData[] GetClientInfo(int Number)
{
structClientData[] objClientDatas = null;
if (Number > 0 && Number <= 10)
{
objClientDatas = new structClientData[Number];
for (int i = 0; i < Number; i++)
{
objClientDatas[i].Name = "Clinet" + Number.ToString();
objClientDatas[i].ID = Number;
}
}
return objClientDatas;
}
}
Will you help me to get the return values from Webservice?
my Need is
if i give input in TextBox as "3" then I get reslut is Client1,
1,Client2,2,Client3 3
|
|
|
|
|
I am having some problems calling stored functions from my c# code, sometimes it works and sometimes it doesn't. When it doesnt I get an error message
"parameter '?9' not found in the collection"
I dont have a parameter with the name '9' in the function I am trying to call! it does it when I call some functions but not others. Another function I call it says it can't find parameter '?50' again I don't have such a parameter
Anyone got any ideas? I have a feeling I'm missing something obvious
///
/// This method executes a stored function
///
/// <param name="functionName" />Name of the function
/// <param name="parameters" />A list of parameters to be passed into the function
/// <returns>The result of the function
public object executeFunction(string functionName, List<parameter> parameters)
{
//this is the variable that will contain the return value from the function
DbParameter returnParam = factory.CreateParameter();
try
{
conn.Open(); //open the connection
//start a transaction
DbTransaction trans;
trans = conn.BeginTransaction();
DbCommand command = factory.CreateCommand(); //create a command
command.Transaction = trans; //set the transaction for the command
command.CommandText = functionName; //set the command text to the name if the function
command.Connection = conn; //set the commands connection
command.CommandType = CommandType.StoredProcedure; //set the type to stored procedure
//add each of the input parameters to the command
foreach (Parameter a in parameters)
{
DbParameter param = factory.CreateParameter();
param.ParameterName = a.name;
param.Value = a.value;
command.Parameters.Add(param);
}
//initialise the return parameter and add it to the command
returnParam.ParameterName = "?rv";
command.Parameters.Add(returnParam);
returnParam.Direction = ParameterDirection.ReturnValue;
command.ExecuteNonQuery(); //execute the function
trans.Commit(); //finish the transaction
conn.Close(); //close the connection
}
catch (Exception ex)
{
throw new Exception("the following exception was thrown: \n" + ex.Message + "\n\nyou probably have an error in your parameters");
}
finally
{
conn.Close();
}
return returnParam.Value; //return the result
}
|
|
|
|
|
Well ... without showing your SQL-statement I can't help you ... and I think the error states that the parameter number 9 is missing!
|
|
|
|
|
That was my initial thought too (and I have double checked I am parring the correct parameters) however I have another function that gives me the error message "parameter '?50' not found in collection" where there are far less than 50 parameters.
|
|
|
|