| | |
Asp.net behind code not correct
Please support our ASP.NET advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Feb 2009
Posts: 54
Reputation:
Solved Threads: 0
hi,
there, im coming up with codes to connect asp.net interface(Track) with asp.net interface(Clerk). i am not sure if my codes are correct. at the same time, i am not sure how to write codes to write the select statement which can connect asp.net interface with sql server. please help.
there, im coming up with codes to connect asp.net interface(Track) with asp.net interface(Clerk). i am not sure if my codes are correct. at the same time, i am not sure how to write codes to write the select statement which can connect asp.net interface with sql server. please help.
ASP.NET Syntax (Toggle Plain Text)
<%@ Page Title="" Language="VB" MasterPageFile="~/MasterPage.master" %> <%@Import NameSpace="System.Data" %> <%@ Import Namespace="System.Data.SqlClient" %> <%@ Import Namespace="System.Configuration" %> <script runat="server"> Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Dim MyConnection As SqlConnection Dim MyCommand As SqlCommand Dim MyReader As SqlDataReader MyConnection = New SqlConnection() MyConnection.ConnectionString = _ ConfigurationManager.ConnectionStrings("ConnectionString2").ConnectionString Dim str As String = "insert into track(TrackingID,PickDATE,Consignment,Reference,Origin,Destination,Status,Destination,RecipientName) Values('" &TextBox1.Text& "','"&TextBox2&"','"&TextBox3.Text&"','" &TextBox4.Text& "','" &TextBox5.Text& "','" &TextBox6.Text& "','" &TextBox7.Text& "','" &TextBox8.Text& "');" Dim Command As SqlCommand = "Select TrackingID.Track from Clerk where (TrackingID.Track=TrackID.Clerk) " MyCommand = New SqlCommand MyCommand.CommandText = "Select " MyCommand.CommandText = MyCommand.CommandText + "'" MyCommand.CommandText = MyCommand.CommandText + "'" MyCommand.CommandText = MyCommand.CommandText MyCommand.Connection = MyConnection MyCommand.Connection.Open() MyReader = MyCommand.ExecuteReader() MyCommand.Dispose() MyConnection.Dispose() End Sub </script>
Last edited by Ezzaral; Apr 16th, 2009 at 11:14 pm. Reason: Added code tags. Learn to use them.
•
•
Join Date: Apr 2008
Posts: 115
Reputation:
Solved Threads: 6
where are you using this:
ASP.NET Syntax (Toggle Plain Text)
Dim str As String = "insert into track(TrackingID,PickDATE,Consignment,Reference,Origin,Destination,Status,Destination,RecipientName) Values('" &TextBox1.Text& "','"&TextBox2&"','"&TextBox3.Text&"','" &TextBox4.Text& "','" &TextBox5.Text& "','" &TextBox6.Text& "','" &TextBox7.Text& "','" &TextBox8.Text& "');"
•
•
Join Date: Feb 2009
Posts: 54
Reputation:
Solved Threads: 0
<%@ Page Title="" Language="VB" MasterPageFile="~/MasterPage.master" %>
<%@Import NameSpace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.Configuration" %>
<script runat="server">
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Response.Redirect("Clerk")
Dim MyConnection As SqlConnection
Dim MyCommand As SqlCommand
Dim MyReader As SqlDataReader
MyConnection = New SqlConnection()
MyConnection.ConnectionString = _
ConfigurationManager.ConnectionStrings("ConnectionString2").ConnectionString
Dim str As String = "insert into Track(TrackingID,PickDATE,Consignment,Reference,Origin,Destination,Status,Destination,RecipientName) Values('" &TextBox1.Text& "','" &TextBox2& "','" &TextBox3.Text& "','" &TextBox4.Text& "','" &TextBox5.Text& "','" &TextBox6.Text& "','" &TextBox7.Text& "','" &TextBox8.Text& "');"
MyCommand = New SqlCommand
MyCommand.CommandText = MyCommand.CommandText + "'"
MyCommand.CommandText = MyCommand.CommandText + "'"
MyCommand.CommandText = MyCommand.CommandText
MyCommand.Connection = MyConnection
MyCommand.Connection.Open()
MyReader = MyCommand.ExecuteReader()
MyCommand.Dispose()
MyConnection.Dispose()
End Sub
</script>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<p>
<br />
</p>
<p>
</p>
<p>
TRACK MY SHIPMENT</p>
<p>
</p>
<p>
</p>
<p>
Tracking ID
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</p>
<p>
</p>
<p>
<asp:Button ID="Button1" runat="server" Text="TRACK" Width="96px" />
</p>
<p>
</p>
<p>
PICK UP
DATE CONSIGNMENT
REFERENCE
ORIGIN DESTINATION
STATUS
RECIPIENT NAME</p>
<p>
<asp:TextBox ID="TextBox2" runat="server" Height="42px" Width="93px"></asp:TextBox>
<asp:TextBox ID="TextBox3" runat="server" Height="42px" Width="93px"></asp:TextBox>
<asp:TextBox ID="TextBox4" runat="server" Height="42px" Width="93px"></asp:TextBox>
<asp:TextBox ID="TextBox5" runat="server" Height="42px" Width="93px"></asp:TextBox>
<asp:TextBox ID="TextBox6" runat="server" Height="42px" Width="93px"></asp:TextBox>
<asp:TextBox ID="TextBox7" runat="server" Height="42px" Width="93px"></asp:TextBox>
<asp:TextBox ID="TextBox8" runat="server" Height="42px" Width="93px"></asp:TextBox>
</p>
<p>
</p>
<p>
</p>
<p>
</p>
<p>
</p>
<p>
</p>
<p>
</p>
<p>
</p>
<asp
qlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString2 %>"
SelectCommand="Select TrackingID from [Clerk] where TrackingID=NationWideAccount"></asp
qlDataSource>
<asp
qlDataSource ID="SqlDataSource4" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString2 %>"
SelectCommand="Select TrackID from [Clerk],[PickUpForm] where PickDATE=PickUp,Consignment=Consignment,Reference=TrackingID,Origin=Address,Destination=Location,Status=Status,RecipientName=RecipientName "></asp
qlDataSource>
</asp:Content>
<%@Import NameSpace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.Configuration" %>
<script runat="server">
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Response.Redirect("Clerk")
Dim MyConnection As SqlConnection
Dim MyCommand As SqlCommand
Dim MyReader As SqlDataReader
MyConnection = New SqlConnection()
MyConnection.ConnectionString = _
ConfigurationManager.ConnectionStrings("ConnectionString2").ConnectionString
Dim str As String = "insert into Track(TrackingID,PickDATE,Consignment,Reference,Origin,Destination,Status,Destination,RecipientName) Values('" &TextBox1.Text& "','" &TextBox2& "','" &TextBox3.Text& "','" &TextBox4.Text& "','" &TextBox5.Text& "','" &TextBox6.Text& "','" &TextBox7.Text& "','" &TextBox8.Text& "');"
MyCommand = New SqlCommand
MyCommand.CommandText = MyCommand.CommandText + "'"
MyCommand.CommandText = MyCommand.CommandText + "'"
MyCommand.CommandText = MyCommand.CommandText
MyCommand.Connection = MyConnection
MyCommand.Connection.Open()
MyReader = MyCommand.ExecuteReader()
MyCommand.Dispose()
MyConnection.Dispose()
End Sub
</script>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<p>
<br />
</p>
<p>
</p>
<p>
TRACK MY SHIPMENT</p>
<p>
</p>
<p>
</p>
<p>
Tracking ID
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</p>
<p>
</p>
<p>
<asp:Button ID="Button1" runat="server" Text="TRACK" Width="96px" />
</p>
<p>
</p>
<p>
PICK UP
DATE CONSIGNMENT
REFERENCE
ORIGIN DESTINATION
STATUS
RECIPIENT NAME</p>
<p>
<asp:TextBox ID="TextBox2" runat="server" Height="42px" Width="93px"></asp:TextBox>
<asp:TextBox ID="TextBox3" runat="server" Height="42px" Width="93px"></asp:TextBox>
<asp:TextBox ID="TextBox4" runat="server" Height="42px" Width="93px"></asp:TextBox>
<asp:TextBox ID="TextBox5" runat="server" Height="42px" Width="93px"></asp:TextBox>
<asp:TextBox ID="TextBox6" runat="server" Height="42px" Width="93px"></asp:TextBox>
<asp:TextBox ID="TextBox7" runat="server" Height="42px" Width="93px"></asp:TextBox>
<asp:TextBox ID="TextBox8" runat="server" Height="42px" Width="93px"></asp:TextBox>
</p>
<p>
</p>
<p>
</p>
<p>
</p>
<p>
</p>
<p>
</p>
<p>
</p>
<p>
</p>
<asp
qlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString2 %>"SelectCommand="Select TrackingID from [Clerk] where TrackingID=NationWideAccount"></asp
qlDataSource><asp
qlDataSource ID="SqlDataSource4" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString2 %>"SelectCommand="Select TrackID from [Clerk],[PickUpForm] where PickDATE=PickUp,Consignment=Consignment,Reference=TrackingID,Origin=Address,Destination=Location,Status=Status,RecipientName=RecipientName "></asp
qlDataSource></asp:Content>
•
•
Join Date: Apr 2008
Posts: 115
Reputation:
Solved Threads: 6
your creating this string:
doesnt appear to be used any where -
give something like this a try:
ASP.NET Syntax (Toggle Plain Text)
Dim str As String = "insert into Track(TrackingID,PickDATE,Consignment,Reference,Origin,Destination,Status,Destination,RecipientName) Values('" &TextBox1.Text& "','" &TextBox2& "','" &TextBox3.Text& "','" &TextBox4.Text& "','" &TextBox5.Text& "','" &TextBox6.Text& "','" &TextBox7.Text& "','" &TextBox8.Text& "');"
doesnt appear to be used any where -
give something like this a try:
ASP.NET Syntax (Toggle Plain Text)
dim connectionstring = SqlConnection(ConfigurationManager.ConnectionStrings("ConnectionString2").ConnectionString) Dim str As String = "insert into Track(TrackingID,PickDATE,Consignment,Reference,Origin,Destination,Status,Destination,RecipientName) Values('" &TextBox1.Text& "','" &TextBox2& "','" &TextBox3.Text& "','" &TextBox4.Text& "','" &TextBox5.Text& "','" &TextBox6.Text& "','" &TextBox7.Text& "','" &TextBox8.Text& "');" Dim scomm As Sqlcommand(str,connectionstring) Dim MyReader As SqlDataReader scomm = scomm.ExecuteReader()
Please mark this post as 'Solved' if it has helped and fixed your issue.
![]() |
Similar Threads
- Updated : Simple ASP.Net Login Page (ASP.NET)
- Asp.net code for sending email (Visual Basic 4 / 5 / 6)
- how to run asp.net pages using apache (ASP.NET)
- How is 3Tier architecture implemented in ASP.NET (ASP.NET)
- Simple ASP.Net Login Page (Using VB.Net) (ASP.NET)
- ASP.NET: Problems with CustomValidator... (ASP.NET)
Other Threads in the ASP.NET Forum
- Previous Thread: error in the programming code
- Next Thread: how to create a dynamic dropdownlist?
Views: 501 | Replies: 5
| Thread Tools | Search this Thread |
Tag cloud for ASP.NET
.net 2.0 3.5 activexcontrol advice ajax application asp asp.net bc30451 bottomasp.net browser businesslogiclayer button c# c#gridviewcolumn chat checkbox child class click compatible confirmationcodegeneration content contenttype countryselector courier css database datagrid datagridview datagridviewcheckbox datalist deadlock development dgv dropdown dropdownmenu edit feedback flash flv folder form forms google grid gridview homeedition hosting identity iframe iis index javascript jquery list menu mono mssql multistepregistration nameisnotdeclared object objects order problem profile ratings refer rotatepage save search security serializesmo.table session silverlight smartcard software sql suse textbox tracking typeof unauthorized update validation vb vb.net video view virtualdirectory vista visual-studio visualstudio vs2008 web webarchitecture webdevelopemnt wizard xml





