Wednesday, March 28, 2012
TableAdaptor Update Access database
or
I have a typed dataset named dsUserInfo
I have a tableadaptor named taFillUserInfo
I would like to on the vb side be able to do update the database when a
button is clicked executing the following code.
if me.textbox1.text = "x" then
taFillUserInfo.text1 = me.textbox1
else
some message
End if
What I can't get is how to "call" my tableadaptor taFillUserInfo to get the
column names.Ysgrifennodd Andre:
> I used the wizard in VS2005 to create my connection, dataset, and tableada
ptor
> I have a typed dataset named dsUserInfo
> I have a tableadaptor named taFillUserInfo
> I would like to on the vb side be able to do update the database when a
> button is clicked executing the following code.
> if me.textbox1.text = "x" then
> taFillUserInfo.text1 = me.textbox1
> else
> some message
> End if
> What I can't get is how to "call" my tableadaptor taFillUserInfo to get th
e
> column names.
>
I can't remember if this answers your question directly, but it should help:
http://www.peredur.uklinux.net/TypedDataSets.pdf
This example project (which is really about forms authentication), uses
a Typed DataSet. It definitely shows you how to use the Typed DataSet
using the column names:
http://www.peredur.uklinux.net/Form...ticationSln.zip
Note that the zip file contains a complete .NET solution. I cannot
guarantee that it is virus-free. I think it is; but I can't guarantee
it. So please examine the code and recompile it before running it.
Both the above use C# rather than VB, but I don't think that should give
you too much trouble. It might even persuade you to use C# :)
HTH
Peter
TableAdaptor Update Access database
I have a typed dataset named dsUserInfo
I have a tableadaptor named taFillUserInfo
I would like to on the vb side be able to do update the database when a
button is clicked executing the following code.
if me.textbox1.text = "x" then
taFillUserInfo.text1 = me.textbox1
else
some message
End if
What I can't get is how to "call" my tableadaptor taFillUserInfo to get the
column names.Ysgrifennodd Andre:
Quote:
Originally Posted by
I used the wizard in VS2005 to create my connection, dataset, and tableadaptor
>
I have a typed dataset named dsUserInfo
I have a tableadaptor named taFillUserInfo
>
I would like to on the vb side be able to do update the database when a
button is clicked executing the following code.
>
if me.textbox1.text = "x" then
taFillUserInfo.text1 = me.textbox1
else
some message
End if
>
What I can't get is how to "call" my tableadaptor taFillUserInfo to get the
column names.
>
>
I can't remember if this answers your question directly, but it should help:
http://www.peredur.uklinux.net/TypedDataSets.pdf
This example project (which is really about forms authentication), uses
a Typed DataSet. It definitely shows you how to use the Typed DataSet
using the column names:
http://www.peredur.uklinux.net/Form...ticationSln.zip
Note that the zip file contains a complete .NET solution. I cannot
guarantee that it is virus-free. I think it is; but I can't guarantee
it. So please examine the code and recompile it before running it.
Both the above use C# rather than VB, but I don't think that should give
you too much trouble. It might even persuade you to use C# :)
HTH
Peter
Tuesday, March 13, 2012
TCP Connection
"Hello world",
i'm a visual c# developer but i'm new to ASP.NET.
My question is this one:
it is possibile to make a TCP connection (opening socket e.g.) from my client application to a my web application asp.net? If so, could you suggest how i can start?
Thank you for any suggestion.
Regards,
Lewix
Yes, you could. You can use the System.Net.Sockets namespace. This contains thatTcpClient object and theTcpListener class. Your Web Application will be the listener in this case, and your client will connect to it using the TcpClient class. However, a much more common means of a client communicating with a Web Application is by the means of SOAPWeb Services.
Thank you for your fast reply! :)
last 2 question, then i hope i don't disturb you again:
- the client have to connect to (for example) "www.mydomain.com/listen.aspx:80" ?
- in the asp code i have to handle a "on http request" event and then i start accepting socket?
Sorry for these strange question but with desktop programming is simpler for me :) for now
Thank you for any suggestion
Lewix
Watch DNR TVhttp://www.dnrtv.com/default.aspx?showID=46
LucidInDreams:
Watch DNR TVhttp://www.dnrtv.com/default.aspx?showID=46
Thank you for the link but it explains how to build a tcp client; i would like to learn how to write a asp code for the asp sever side (tcplistener i think)
If you click on the TcpListener link in my above post, the page will show you an example of how to use that class.
So if your question is how to write client on Web, here is the answer:
<%@. Page Language="C#" AutoEventWireup="false" Trace="true" %><%@. Import namespace="System.Data"%><%@. Import namespace="System.Net"%><%@. Import namespace="System.Net.Sockets"%><script language="C#" runat="server">protected override void OnInit(EventArgs e){base.OnInit(e);this.Load += new EventHandler(this.Page_Load);}protected void Page_Load(object sender, EventArgs e){string host = "www.asp.net";string path = "/resources/default.aspx?tabid=41";int port = 80;string result = this.SocketSendReceive(host, port, path); this.Trace.Warn(result);}private static Socket ConnectSocket(string server, int port){Socket s = null;IPHostEntry hostEntry = null;// Get host related information.hostEntry = Dns.GetHostEntry(server);// Loop through the AddressList to obtain the supported AddressFamily. This is to avoid// an exception that occurs when the host IP Address is not compatible with the address family// (typical in the IPv6 case).foreach(IPAddress address in hostEntry.AddressList){IPEndPoint ipe = new IPEndPoint(address, port);Socket tempSocket = new Socket(ipe.AddressFamily, SocketType.Stream, ProtocolType.Tcp);tempSocket.Connect(ipe);if(tempSocket.Connected){s = tempSocket;break;}else{continue;}}return s;}// This method requests the home page content for the specified server.private string SocketSendReceive(string server, int port, string path) {// Create a socket connection with the specified server and port.Socket s = ConnectSocket(server, port);if (s == null)return ("Connection failed"); string request = "GET "+path+" HTTP/1.1\r\nHost: " + server + "\r\nConnection: Close\r\n\r\n";byte[] bytesSent = Encoding.ASCII.GetBytes(request);byte[] bytesReceived = new Byte[256];// Send request to the server.s.Send(bytesSent, bytesSent.Length, 0); // Receive the server home page content.int bytes = 0;StringBuilder sb = new StringBuilder();// The following will block until te page is transmitted.do {bytes = s.Receive(bytesReceived, bytesReceived.Length, 0);sb.Append( Encoding.ASCII.GetString(bytesReceived, 0, bytes) );}while (bytes > 0);return sb.ToString();}</script>And if you are asking how to build web server, then my question is: Why not having web service if this will be web server based? In the dnrtv example they also have server by the way...
Thank you to all, really.
All yu helped me helped me for all i needed (sorry for my orrible english, i'm italian).
for LucidInDreams : thank you, no i don't need to build a web server, i was interested only to asp code tu build a socket connection. I was warried it was very different from c#, instead it is similiar :)
Thank you to all again! :)
Lewix
TcpClient connection in app_code fails to work
Hello,
I am just getting into asp.net development (have a winforms background)
I have a sockets server running on my windows 2003 machine. I made a class called ClientTcp that opens a new connection and sends a string to the server and placed this in APP_CODE.
I call ClientTcp :
public class ClientTCP{private TcpClient tcpClient;public void SendData(String toSend) { tcpClient =new TcpClient(CONNECT_ADDR, CONNECT_PORT); NetworkStream networkStream = tcpClient.GetStream(); StreamWriter streamWriter =new StreamWriter(networkStream, System.Text.Encoding.ASCII); streamWriter.WriteLine(toSend); streamWriter.Flush(); }}
From my code behind Default.aspx.cs:
ClientTCP c =new ClientTCP();c.SendData("In app_code"); This works great on my local VS 2005 debug but when this runs under IIS 6 on Windows 2003 no data is received by the socket server.
Is there some sort of permissions issue or scope issue with using a class in APP_CODE
Interesting enough if I place the SendData method directly in the Default.aspx.cs file then it opens a socket connection and sends the data.
I have looked around for clues but could not find out why the socket wont connect and send by calling a code behind.
Thanks
I have solved this isssue.
I didn't post the complete method in my earlier post. This code works correctly.
My issue was that I was attempting to build an XmlDocument and then converting that to a string and sending that string over the stream.
It seems that I cannot create an XmlDocument in memory under IIS6. Creating a temporary file and then using this may solve the real issue but I have worked around this by building a custom string builder to generate xml compliant strings.
Thanks