How can I access data to SQL server 2005 using Windows form application,ADO.net and .Net remoting?
Can anybody help me? please...
This question is too vague. Do you have a specific issue or question?|||Here is one place to start:
http://www.411asp.net/home/tutorial/howto/applicat
I suggest that you go to your local bookstore or library and look over the options. Or Google?
|||"create .NET application"
Deepak Kapoor wrote:
This question is too vague. Do you have a specific issue or question?
Hi ! Deepak Kapoor
I am a C# beginner, I have to write some code using windows application,that's need to INSERT,UPDATE,SELECT and DELETE data to sql server using ADO.net and .net remoting...
1.The client application include 1 dataGridView and 4 buttons(Add,Delete,Edit and Load).
2.The server application include 1label and 1 button to start server application.
3.The remote object.
Here are my questions.
I already wrote for the Load button of the client application.But, I dont know how to program for the remaining buttons.And I want to access data directly into the dataGridView.If you know how to do,please post some explaination and give me some example code.
This is my remote object.
public class AuthorList : MarshalByRefObject
{
private static string connectionString = @."server = BMSTU\KTS ;database = kts;uid=sa;pwd=";
public DataTable GetAuthors()
{
string SQL = "SELECT * FROM Author";
// Create ADO.NET objects to execute the DB query.
SqlConnection conn = new SqlConnection(connectionString);
SqlCommand cmd = new SqlCommand(SQL, conn);
SqlDataAdapter adapter = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
// Execute the command.
try
{
conn.Open();
adapter.Fill(ds, "Author");
}
catch (Exception err)
{
Console.WriteLine(err.ToString());
}
finally
{
conn.Close();
}
// Return the first DataTable in the DataSet to the caller.
return ds.Tables["Author"];
}
// This method allows you to verify that the object is running remotely.
public string GetHostLocation()
{
return AppDomain.CurrentDomain.FriendlyName;
}
}
This is the Server application.
private void button1_Click(object sender, EventArgs e)
{
HttpChannel myChannel = new HttpChannel(8080);
ChannelServices.RegisterChannel(myChannel);
RemotingConfiguration.RegisterWellKnownServiceType(typeof(BookServer.AuthorList),
"AuthorList", WellKnownObjectMode.Singleton);
label1.Text = "Server Started";
button1.Enabled = false;
}
This is the Client application
private void btnLoad_Click(object sender, EventArgs e)
{
AuthorList atlst = (AuthorList)Activator.GetObject(typeof(AuthorList),
"http://localhost:8080/AuthorList", WellKnownObjectMode.Singleton);
dataGridView2.DataSource = null;
dataGridView2.DataSource = atlst.GetAuthors();
}
If you know how to program for the btnAdd,btnEdit and btnDelete of the Client application.And how to program in server and remote object.I am hoping anybody's help.
Best regards ,
thanks,
WhoAmI?
|||hmmm, can anyone help me?
No comments:
Post a Comment