E
Ed Dror
Hi there,
I have ASP
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Guestbook.aspx.vb"
Inherits="Guestbook" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<span style="font-family: Verdana"><strong>Guestbook<br />
<br />
</strong>
<table>
<tr>
<td style="width: 100px">
<span style="font-size: 10pt">
FirstName</span></td>
<td style="width: 100px">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td style="width: 100px">
<span style="font-size: 10pt">
LastName</span></td>
<td style="width: 100px">
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td style="width: 100px">
<asp:Button ID="Button1" runat="server" Text="Submit" /></td>
<td style="width: 100px">
</td>
</tr>
</table>
<br />
</span>
<br />
</div>
</form>
</body>
</html>
And VB
Imports System.Data
Imports System.Data.SqlClient
Public Class ProductInfo
Const conString As String = _
"Server=localhost;Trusted_Connection=true;Database=Northwind"
Public Function MyInsertMethod() As Integer
Dim con As New SqlConnection(conString)
Dim insertString As String = "INSERT INTO Guests (FirstName, LastName)
VALUES ('" & FirstName.Text & "','" & LastName.Text & "')"
Dim cmd As New SqlCommand(insertString, con)
con.Open()
cmd.ExecuteNonQuery()
con.Close()
End Function
End Class
Partial Class Guestbook
Inherits System.Web.UI.Page
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click
Call MyInsertMethod()
End Sub
End Class
I'm getting an error FirstName must be declared
And Call MyInsertMethod must be declared
How do I fixed that and insert a FirstName and LastNAme into database
Thanks,
Ed Dror
I have ASP
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Guestbook.aspx.vb"
Inherits="Guestbook" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<span style="font-family: Verdana"><strong>Guestbook<br />
<br />
</strong>
<table>
<tr>
<td style="width: 100px">
<span style="font-size: 10pt">
FirstName</span></td>
<td style="width: 100px">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td style="width: 100px">
<span style="font-size: 10pt">
LastName</span></td>
<td style="width: 100px">
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td style="width: 100px">
<asp:Button ID="Button1" runat="server" Text="Submit" /></td>
<td style="width: 100px">
</td>
</tr>
</table>
<br />
</span>
<br />
</div>
</form>
</body>
</html>
And VB
Imports System.Data
Imports System.Data.SqlClient
Public Class ProductInfo
Const conString As String = _
"Server=localhost;Trusted_Connection=true;Database=Northwind"
Public Function MyInsertMethod() As Integer
Dim con As New SqlConnection(conString)
Dim insertString As String = "INSERT INTO Guests (FirstName, LastName)
VALUES ('" & FirstName.Text & "','" & LastName.Text & "')"
Dim cmd As New SqlCommand(insertString, con)
con.Open()
cmd.ExecuteNonQuery()
con.Close()
End Function
End Class
Partial Class Guestbook
Inherits System.Web.UI.Page
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click
Call MyInsertMethod()
End Sub
End Class
I'm getting an error FirstName must be declared
And Call MyInsertMethod must be declared
How do I fixed that and insert a FirstName and LastNAme into database
Thanks,
Ed Dror