|
Hi,
How can I store data of Gridview to a table of SQL Database.? For Example:
The Gridview has following columns:
1. Name
2. Country
3. Job
4. DOB5. Email
All these data in the Gridview should be stored in the table named "contacts" under right columns (Name,Country, Job, DOB, Email) in SQL.
Please advise on how to implement this using VB.NET.
|
|
|
|
|
Quote: Gridview-Displays the values of a data source in a table where each column represents a field and each row represents a record. The GridView control enables you to select, sort, and edit these items.
This is what MSDN Says.
Gridview is used to display the data which is bind from either database or from datatable.
If you wants to store data in database then get the datasource and insert it.
To learn all there is to know. I know I'll be disappointed one day, but I've made a good start, and the eventual disappointment is likely to be brief.
-Roger Wright
|
|
|
|
|
Dear Folk,
You first need to create an table named "Contact" within your database,
Query will be :
Create table contact
(
Contact_ID int IDENTITY(1,1) not null,
Name varchar(100) null
Country varchar(100) null
Job varchar(100) null
DOB datetime null,
Email varchar(50) null
CONSTRAINT PK_Contact PRIMARY KEY ([Contact_ID])
)
Doing so you get the table schema where you dump the data from front end [your page].
|
|
|
|
|
Hi Ajay,
Thank you for your reply,
All what i need is I was able to bind data from an excel file to gridview. Now the data from the Gridview need to be imported to the table in SQL. Therefore, how can we loop through each record in Gridview and store in respective columns in SQL table?
|
|
|
|
|
Try like this in Button click event
protected void Button1_Click(object sender, EventArgs e)
{
for (int i = 0; i <= GridView1.Rows.Count;i++ )
{
Label box1 = (Label)GridView1.Rows[i].Cells[1].FindControl("label1");
Label box2 = (Label)GridView1.Rows[i].Cells[2].FindControl("label2");
}
}
You have to learn to think like a computer or teach him to think like a human...
----Kornfeld Eliyahu Peter
|
|
|
|
|
Hi,
I have developed a ASP.net Website (Razor 2) in VS 2012. I have a class which sent mail using System.Web.Helpers.WebMail.Send() method. This method has 13 Parameters and it works fine locally.
After uploading the same project on TFS 2012 it gives exception stating too many arguments for System.Web.Helpers.WebMail.Send() method.
Below is the Snippet of code which works fine before adding to TFS 2012
WebMail.Send(EmailTo, MailHeader, MailBody, EmailFrom, , , False, , "abc@gmail.com", , , , )
Error after adding on TFS 2012
Too many arguments to 'Public Shared Sub Send(to As String, subject As String, body As String, [from As String = Nothing], [cc As String = Nothing], [filesToAttach As System.Collections.Generic.IEnumerable(Of String) = Nothing], [isBodyHtml As Boolean = True], [additionalHeaders As System.Collections.Generic.IEnumerable(Of String) = Nothing])'
Regards.
Thanks.
|
|
|
|
|
trevor15 wrote: Too many arguments Is that message not clear enough? The Send method takes upto 8 arguments, and how many arguments do you pass? More than 10.
|
|
|
|
|
System.Web.Helpers.WebMail.send takes 13 parameters.
'Declaration
Public Shared Sub Send ( _
to As String, _
subject As String, _
body As String, _
from As String, _
cc As String, _
filesToAttach As IEnumerable(Of String), _
isBodyHtml As Boolean, _
additionalHeaders As IEnumerable(Of String), _
bcc As String, _
contentEncoding As String, _
headerEncoding As String, _
priority As String, _
replyTo As String _
)
If the project if built outside TFS den it work fine without errors.
|
|
|
|
|
I am designing a webpage to show all data after scrolling auto. I choose datagrid to show data but I do not know how to scroll all rows of datagrid that freezes it's header (scrolling from down to up like marquee tag in HTML).Please give me some advices
|
|
|
|
|
You can refer to this[^] for it.
.AK.
|
|
|
|
|
Thanks for your replying. Maybe, you misunderstood my idea. It mean that I want to insert "<marquee>" tag into Datagrid to running auto all rows following up to. Please help me, thanks a lot.
|
|
|
|
|
Hi all,
This problem is coming at an ugly time.
The app goes LIVE in 3.5 hours and here I am having issues.
We have two tables.
One table has username and password
The other table has username and password.
Problem is that username for one table is different from username from another table.
According to users, this was designed intentionally.
So, when a user attempts to log in, the code is supposed to check one table for existence of user's info. If not there, check another table.
This code is failing me.
Can someone please help?
Thanks alot in advance
MySQL = "select COUNT(*) from employees e " & _
"left join members r " & _
"on e.ssn = r.ssn WHERE (e.empl_login='" & txtUser.Text & "' AND e.empl_ssn = '" & txtPassword.Text & "') or (r.empl_login='" & txtUser.Text & "' AND r.empl_ssn = '" & txtPassword.Text & "')"
|
|
|
|
|
Firstly, what has this got to do with ASP.NET? It looks like a database question to me.
Secondly, if that's what your code looks like, then going live today is not an option. You urgently need to learn about SQL Injection[^], and then fix this major vulnerability in your code.
Thirdly, based on your query, it looks like you're storing passwords in plain-text. That is a very bad idea; you should be storing salted password hashes instead. See Salted Password Hashing - Doing it Right[^] for more details.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hi,
I tried with your query. it's working fine for me.
Table Structure
CREATE TABLE [dbo].[employees] (
[Id] INT NOT NULL,
[username] NVARCHAR (50) NULL,
[ssn] NCHAR (10) NULL,
[password] NCHAR (10) NULL,
PRIMARY KEY CLUSTERED ([Id] ASC)
);
CREATE TABLE [dbo].[members] (
[Id] INT NOT NULL,
[username] NVARCHAR (50) NULL,
[ssn] NCHAR (10) NULL,
[password] NVARCHAR (50) NULL,
PRIMARY KEY CLUSTERED ([Id] ASC)
);
Data
Members Table
INSERT INTO [dbo].[members] ([Id], [username], [ssn], [password]) VALUES (1, N'name3', N'123456700 ', N'pass3')
INSERT INTO [dbo].[members] ([Id], [username], [ssn], [password]) VALUES (2, N'nameOne', N'123456789 ', N'passOne')
INSERT INTO [dbo].[members] ([Id], [username], [ssn], [password]) VALUES (3, N'nameTwo', N'987654321 ', N'passTwo')
Employees Table
INSERT INTO [dbo].[employees] ([Id], [username], [ssn], [password]) VALUES (1, N'name1', N'123456789 ', N'pass1 ')
INSERT INTO [dbo].[employees] ([Id], [username], [ssn], [password]) VALUES (2, N'name2', N'987654321 ', N'pass2 ')
SQL
SELECT count(*)
FROM employees e JOIN members r ON e.ssn = r.ssn
WHERE (e.username='name1' AND e.ssn = '123456789')
OR (r.username='name1' AND r.ssn = '123456789')
If possible can you share your table data and structure ?
|
|
|
|
|
Arun Radhakrishnan wrote: If possible can you share your table data and structure ?
... and the link to your app
--
"My software never has bugs. It just develops random features."
|
|
|
|
|
Hello,
Please let me know why we lost the session in our web application after exception, notice that all the code contains try-catch block.
Thank you
|
|
|
|
|
check the timeout value of sessionstate in your web.config. May be you have given very less. Session variable doesn't depend on try catch. Its only used to handle errors.
In addition sessions will not work locally or on the server unless you are running https (note the S on the end of https), if you have the following in your web.config file:
<httpcookies httponlycookies="true" requiressl="true">
|
|
|
|
|
kaushikpathak wrote: In addition sessions will not work locally or on the server unless you are
running https (note the S on the end of https),
I'm sorry, but that is just absolute cobblers....nonsense
C# has already designed away most of the tedium of C++.
|
|
|
|
|
We solve the problem by change logfile location from bin to any folder outside the bin folder.
|
|
|
|
|
HI All,
We develop a web application and when the user loggedin I save the userID in the session["UserID"] and at the each page_load we check the session if null we log off and redirect to loginpage.
My problem if any exception occurred and enter to catch block the session["UserID"] being NULL and log off the user.
Please help me to know why the session be a null if any exception occurred. and note that all the methods and code we set them in a try-catch block and we write the code to a log file.
This is an error:::
" unable to evaluate expression because the code is optimized or a native frame is on top of the call stack"
Thank you very much.
modified 18-Mar-14 5:17am.
|
|
|
|
|
Hi, now i need to create dropdownlist calling data from sql server database.
Dropdownlist item from database
-Louis
-Louis
-William
-William
but i dont want to repeat the word, i need the dropdownlist like this
-Louis
-William
can help me the coding?Thx
|
|
|
|
|
try and check the IsPostBack in the page load
|
|
|
|
|
In the query that returns the list from the database add the DISTINCT keyword
e.g. SELECT DISTINCT [ColumnName] FROM [TableName]
=========================================================
I'm an optoholic - my glass is always half full of vodka.
=========================================================
|
|
|
|
|
I use this code to redirect aspx page :
in locahost that run open Default.aspx page
but in http://tracklocation.somee.com/LocationService.asmx
it do not any thing . Somebody help me
[WebMethod]
public string DataLocation(string location)
{
string url = "http://tracklocation.somee.com/Default.aspx?id=" + location
Context.Response.Redirect(url);
location = Server.UrlDecode(location);
return location;
}
|
|
|
|
|
let your web service return the url to redirect to, and redirect to it from the calling web page.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|