Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
My code is not working. #X is my parameter ans ASP.NET shows error near #X parameter.
Please help.
SqlCommand cmd = new SqlCommand("SELECT top #x * FROM tblname",cn);
cmd.Parameters.AddWithValue("#x",DropDown1.SelectedItem.value);
SqlDataReader dr;
dr=cmd.executeReader();
DataList1.DataSource = dr;
DataList1.DataBind();
Just change SELECT statement this way:
SELECT top (#x) * from tblname
I only includes the brackets around #x parameter
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
SELECT sysxml.XPathValue(O.CAST(xmlOrder VARCHAR(1000) CHARACTER SET UNICODE), '//ORDER/PO_NUMBER/*') AS PO_Number,
sysxml.XPathValue(O.CAST(xmlOrder VARCHAR(1000) CHARACTER SET UNICODE), '//ORDER/DATE/*') AS theDate
FROM COMMON.OrderLog O
WHERE sysxml.XPathValue(O.CAST(xmlOrder VARCHAR(1000) CHARACTER SET UNICODE), '//ORDER/BILLTO/*') = 'Mike';
The CAST is not part of O, and xmlOrder probably is.
So instead of this:
O.CAST(xmlOrder ...
you probably need to do this in all three lines:
CAST(O.xmlOrder ...
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
This is the output of joining 2 tables by inner join.
I want linq query of joing two table as inner join and group by name from one table and sum of total from another table column as taken snapshot as above.pls help
Check this post.
var result = (from a in ctx.TableA
join b in ctx.TableB on a.Id equals b.Id
group a by a.Name into g
select new
{
Name = g.Key,
Sum = g.Sum(i => i.Total)
}).ToList();
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I want to retrieve something from a database in vb.net and display it. It has 4 columns with unlimited amounts of rows, could be 5, could be 10.
First column is an int, second a name, 3rd date and 4th a date. I have to sort it by date. What would be the best way to retrieve all the data and store it?
One solution I thought of was to store each individual column into an array then sort them, but I am not sure how to sort more than 2 arrays. The next solution I though of was to use a datatable and organizing the columns but I am just not sure how to do.
Any ideas?
store the data in a Table inside of a dataset. If you do this then you can select all of the SQL information at once, throw it into the dataset's table and then display it in something like a datagrid.
Be sure to include for SQL:
Imports System.Data.SqlClient
Dim conn As New SqlConnection
conn.ConnectionString = "YOUR CONNECTION INFORMATION"
Dim sQuery As String = "SELECT [Number], [Name], [Date], [Date2] " & _
"FROM [YourTableName] " & _
"ORDER BY [Date]"
Dim da As New SqlDataAdapter(sQuery, conn)
Dim ds As New DataSet
Dim dt As New DataTable()
da.Fill(ds, sQuery)
dt = ds.Tables(0)
dgvYourDataGridView.DataSource = ds
dgvYourDataGridView.Refresh()
conn.Close()
conn.Dispose()
Not sure if that's what you're looking for or not.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I want to update details using linq to entities. But instead of takin a new aspx page i want to update details in another view. will it work.? and please give the linq to entity update query
Let us assume:
db is the context of your Database Entity.
Table_name is the name of Table you need to update.
row_id is the value you are using to search for the data in the Table.
To update using linq you need to fetch the record first using the below query:
var data = (from r in db.Table_name
where r.id == row_id
select r).FirstOrDefault();
Now to update the values just update them. For example:
data.Name = "Firstname lastname"
data.IsActive = true;
.
.
and so on
After you have updated the values in data you need to Save the changes made by you by this command:
db.SaveChanges();
That's it.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
Does anyone know of a script to download email from Gmail and store it to a SQL server? (for backup purposes)
I am looking for a .NET solution (C#).
EML files are plain text.
Simply create a table in your database with one column (and all the others you need, that's for you to decide) of type nvarchar(max) that will store the contents of the email file. For example call this column email_content
Then do something like this:
string email = File.ReadAllText("Path/to/EML/File");
And then do something like:
using (SqlConnection con = new SqlConnection("YourConnectionStringHere"))
{
con.Open();
using(SqlCommand command = new SqlCommand("INSERT INTO your_table (email_content) values (#email_content)",con)
{
command.Parameters.AddWithValue("#email_content",email);
command.ExecuteNonQuery();
}
}
*That's assuming you are using SQL Server but the principle is the same for any other database.