Hi. I have created two tables :Artist and Song .Artist table has fields Artistid and ArtistName and Song table has SongID, Lyrics,Description and Artistid as the secondary key.I have a web form to add new artist containing a textbox and submit button . The code is as below :
<head id="Head1" runat="server">
<title></title>
</head>
<body>
<form id="form1" method ="post">
<div style="width: 960px; color: black; border: 2px solid black; padding: 5px; text-align:"center">
<table>
<tr>
<td> <label>Artist: </label>
<input type="text" name ="textArtist" id ="txtartist" value = "" />
</td>
</tr>
<tr>
<td>
<p align="center" >
<input type = "button" id= "btnArtist" value ="submit" />
</p>
</td>
</tr>
</table>
</div>
</form>
</body>
My requirement is that I will enter some name in textbox and click on submit , the same name should be shown in artist table in the database .
I have also created a namespace using Mygenerations with the artist and song table . I have written the foll code but it does not show the data in database .it does not work properly . Please help.
The code behind file is as below :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using NCI.EasyObjects ;
using TestSong ;
public partial class _Default : System.Web.UI.Page
{
string strcon = "Company";
protected void Page_Load(object sender, EventArgs e)
{
}
void btnartist_onclick(object sender, EventArgs e)
{
string s_artistname = textArtist.Value;
Artist oArtist = new Artist(strcon);
oArtist.Where.ArtistName.Value = s_artistname;
if (!oArtist.Query.Load())
{
oArtist.AddNew();
oArtist.ArtistName = textArtist.Value;
oArtist.Save();
}
}
}
Also i am getting an error for the line that has textArtist.Value . the error is textArtist does not exist in current context. Please tell me where m going wrong .