DataGrid Updation Problem !!

Jan 19, 2004

Hello all


i am trying to update the database with the DataSet (Updated from the DataGrid) but it is giving the error as


"Dynamic SQL generation for the UpdateCommand is not supported against a SelectCommand that does not return any key column information."


the code is as follows








public DataSet bindControlToGrid(DataSet dataSet)


{


SqlConnection objConn= null;


SqlCommand objComm = null;


try


{


objConn = new SqlConnection(@"User ID=sa;Password=sa;database=ExtraNet;server=EAGLESEAGLES");





SqlDataAdapter objAdapter=new SqlDataAdapter();


objAdapter.SelectCommand= new SqlCommand("SELECT sUserID,sUserName FROM tblUser WHERE dUserDeActivated IS NULL ORDER BY sUserName,nUsrSerialNo",objConn);


SqlCommandBuilder sqlCommandBuilder = new SqlCommandBuilder(objAdapter);


objConn.Open();


DataSet objdataSet= new DataSet("ko");


string d = (dataSet.Tables[0].Rows[0].ItemArray.GetValue(0).ToString());





objAdapter.Fill(objdataSet);


objAdapter.Update(dataSet);


objAdapter.Dispose();


}


catch(Exception ex)


{


string s= ex.Message;


}


finally


{


//objComm.Dispose();


objConn.Close();


}


return dataSet;


}





kindly help

View 1 Replies


ADVERTISEMENT

Updation

Jun 18, 2007

Hello,
 I want to update a field value with its default constraint value defined. how can i do that?
 Suppose if it is a Date field, my default date value is 1/1/2000 and currently it contains 6/18/2007, i would like to know how can we update this field with default value.
 Thanks for all your help,
General Problem

View 2 Replies View Related

Updation

Apr 22, 2008

I have table in that created column is there
it has the data like
23
24
45
45
43
67
by mistake if i updated that column as 77
can we roolback to old date

View 1 Replies View Related

Automatic Updation

Jul 14, 2000

Hi all,
I am using the odbc connector to get a local table. I want that table to get populated every night automatically. How can i do that? Also i want to check if any existing record is updated/changed in the dsn database. Any help is highly appreciated.
Thanks,
Jeff.

View 1 Replies View Related

Re:Updation On Table

Nov 20, 2000

Hi Guys,
When iam trying to update the table with the field called "openstatus" is smallint . Iam trying to do following like this
update table1
set openstatus=2 where openstatus=NULL
But
iam getting error like this:

"Syntax error converting the varchar value 'NULL' to a column of data type smallint."
Could you please let me how to solve this proble. i really appreciate it.

Thanks in advance
Garir

View 2 Replies View Related

Failure During Updation

Jan 18, 2005

In SQL SERVER if there is failure during updation of certain rows, what will be the state?

View 3 Replies View Related

Tables Updation

Sep 11, 2007

Dear all,
i've one database in my server namely mydb1, and another database mydb2. same type of tables are there. in those tables, when ever developers are entering data, that should be automatically updated here also.
i think replication suits this.

daily maximum 200 transactions may occur in the mydb1.

if replication suits this, which replication can i use..and please guide me for the process....

and one more doubt...actually only 22 tables out 0f 1300 tabls will modify regularly... rest of those are not changed frequently...

Vinod
Even you learn 1%, Learn it with 100% confidence.

View 7 Replies View Related

Updation Of Value In Table In Database

Mar 12, 2008

hi i cant update the values in the table from data base if i do so an error message will show as below
No row was updated .
The data in row 37 was not committed.
Error Source: Microsoft.VisualStudio.DataTool.
Error Message: The row values updated or deleated either do not make the row unique or they alter multiple rows(2 rows)

View 2 Replies View Related

Updation Problem In Sql Server

Jul 20, 2004

i have a table which have 64 columns.
Problem:
When i update a column through stored procedure like

Column1=400

then after update when i see that value which is 100 but that will 400
So how this problem occured.

View 1 Replies View Related

Checking Is Updation Successfull

Nov 23, 2006

I am updating a table in store procedure. I want to check whether the statement has successfully updated the table or not. i know in mySql i can handle it using ROW_COUNT() function. but how can i do it in MS-SQL?

View 2 Replies View Related

Sys.databases Table Updation Possible????

May 1, 2007

Dear Folks,
Is it possible to update sys.databases table?

i need to update one column in this table.........

but it is showing some error

Msg 259, Level 16, State 1, Line 2
Ad hoc updates to system catalogs are not allowed.


how can i update this table?



Vinod

View 4 Replies View Related

Insertion / Updation Problem In SSIS

May 30, 2006

€œI have a scenario where i am trying to insert 200,000 lac records & update 200,000 lac record in destination table using SISS Package (SQL SERVER 2005) but I am not able to neither update nor insert the records . while executing the package its not showing any error also . what could be the problem ? €œ

We have business logic in Package creation 1) Insert New records and 2) Update Existing Records using the follow Data flow diagram
For update we are using OLEDB command, for insert we are using OLEDB Destination.
We are using merge join for spliting record into insert and update.

View 7 Replies View Related

Transact SQL :: Updation On Encrypted Column

Jul 11, 2011

I have a table having 1 column whose value have to update,the column is encrypted using symmetric encryption. Value in column is 0 in char form, I have to increment it, when retrieving it return 0 to increment i have to convert it to int,it becomes 48 after increment it is 49 after conversion to char it becomes 1. It is going right upto 9 after 10 it jumps to very large number on increment.

View 5 Replies View Related

Transactional Replication With Immediate Updation DBNETLIB Problem.

Mar 13, 2006

Hi,


I am trying to set up Transactional replication with immediate
updation.


The configuration is as follows:


1. Publisher is SQL server 2000 Enterprise Edition, and Distributor is
on the same server.
2. Publisher SQL server Standard Edition is installed on Windows 2003 with sp1.
3. Subscriber is an SQLServer 2000 Evaluation version on Windows
Professional 2000 with sp2.


When I set up the Publisher with transactional replication with
immediate updation only, the set up was successful.
I subscribed 2 instances of SQL server from Windows 2000 professional
on the local LAN in the same domain. The set up went fine.


When I update from the publisher end the updation is successfully
replicating to all the subscribers. But when I try to insert any
records in any one of the subscribers, I am getting the following
error:


[Microsoft] [ODBC SQL Server Driver ][SQL Server
][DBNETLIB][ConnectionOpen(Connect()).] SQL Server does not exists or
access denied.


I am beginner to this replication technology, but I have to set up in
my organisation. Please anybody help me in figuring out the actual
problem and resolving it.


Thanks in advance.


Prashant N M

View 4 Replies View Related

Conditional Insertion && Updation In Destination Table (SSIS)

May 25, 2006

HI,
How to create package in SSIS by applying the business Logic like if the record already exist it should be and update else it should be an insert in the destination table. how to achive this funcality in SQL SERVER 2005 (Business Intelligence studion).

Thanks & Regards

Nagaraj.S



View 4 Replies View Related

SQL And DataGrid

Aug 10, 2007

I need to take 8 indiviual parts of a table and combine then into 1 Column of a Datagrid.  Is this even possible, if so how?
 example:
The DB contains:
Comp1 Comp2 Comp3 ... Comp8
 
The DG should say
header --> Comp
Data --> Comp1, Comp2, Comp3, ..., Comp8
 

View 4 Replies View Related

Datagrid

May 6, 2004

hey all

i have 2 tables
1. Location (locid, name)
2. Product (pid, locid, productname, ...etc)

right now i do a select * from product where locid ='locid', and a datagrid with colums
ProductId | ProductName | AvailableIn

how do i do a select * from Location where locid ='locid' and show Location Name in the datagrid?

ProductId | ProductName | AvailableIn
123456 | testing | Somewhere (instead of the locid)

thanks

View 2 Replies View Related

Can Not Update In DataGrid - C#

Aug 29, 2006

Here is my code : string    connstring = System.Configuration.ConfigurationSettings.AppSettings["myconn"];        string selectquery =  "Select * from nhacungcap";        protected System.Web.UI.WebControls.DataGrid DataGrid1;        string insertquery = "Insert into nhacungcap(mancc,tenncc,diachi,dienthoai) values(@mancc1,@tenncc1,@diachi1,@dienthoai1)";string updatequery = "Update nhacungcap set mancc=@mancc, tenncc=@tenncc, diachi=@diachi, dienthoai=@dienthoai where (mancc=@mancc)";            myconnection.Open();            SqlCommand updatecommand = new SqlCommand(updatequery,myconnection);// sua truong mancc            updatecommand.Parameters.Add(new SqlParameter("@mancc",SqlDbType.VarChar,10));            updatecommand.Parameters["@mancc"].Value = DataGrid1.DataKeys[e.Item.ItemIndex];// sua truong tenncc            updatecommand.Parameters.Add(new SqlParameter("@tenncc",SqlDbType.NVarChar,50));            updatecommand.Parameters["@tenncc"].Value = ((TextBox) e.Item.Cells[3].Controls[0]).Text;// sua truong diachi            updatecommand.Parameters.Add(new SqlParameter("@diachi",SqlDbType.NVarChar,200));            updatecommand.Parameters["@diachi"].Value = ((TextBox) e.Item.Cells[4].Controls[0]).Text;// sua truong dienthoai            updatecommand.Parameters.Add(new SqlParameter("@dienthoai",SqlDbType.Char,10));            updatecommand.Parameters["@dienthoai"].Value = ((TextBox) e.Item.Cells[5].Controls[0]).Text;// kiem tra lenh thuc thi            int result1 = updatecommand.ExecuteNonQuery();                         myconnection.Close();// dieu kien kiem tra            if (result1 > 0 )             {                lbcheck.Text = "Cập Nhật Thành công  !";            }// hien thi du lieu                        hienthidulieu();  And my error appear, when I edit value in datagrid, I only update all value fields, without value @mancc . Hu hu hu, I don't know what i must do with it.

View 1 Replies View Related

Datagrid Delete

Jul 24, 2007

Hi I'm having a problem deleting rows from my datagrid. Basically I hit delete and a message box pops up and asks if Im sure I want to delete so I hit yes and then I get the following error --> Could not find stored procedure 'delete from SECTION_TBL where SECT_ID = @SECT_ID'.
 Is it my code thats wrong or is our test sql server that is the problem?1 <%@ Page Language="VB" EnableEventValidation="True" MasterPageFile="~/MasterPage.master" Title="Untitled Page" %>
2 <%@ import namespace="System" %>
3 <%@ import namespace="System.Data" %>
4 <%@ import namespace="System.Data.SqlClient" %>
5
6 <script language="VB" runat="server">
7
8 Dim section As String
9 Dim myconnection As SqlConnection
10 Dim myda As SqlDataAdapter
11 Dim ds As DataSet
12
13 Sub Page_Load(ByVal Source As Object, ByVal E As EventArgs)
14 BindData()
15 End Sub
16
17 Sub BindData()
18
19 Dim strConn As String = "server=fileserver; uid=xxx; pwd=xxx; database=NEW_CMS"
20 Dim sql As String = "Select * from SECTION_TBL"
21 myconnection = New SqlConnection(strConn)
22 myda = New SqlDataAdapter(sql, myconnection)
23 ds = New DataSet
24 myda.Fill(ds, "SECTION_TBL")
25 sectList.DataSource = ds
26 sectList.DataBind()
27
28 End Sub
29
30 Private Sub sectList_ItemDataBound(ByVal sender As Object, ByVal e As DataGridItemEventArgs) Handles sectList.ItemDataBound
31
32 Dim l As LinkButton
33
34 If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
35 l = CType(e.Item.Cells(0).FindControl("cmdDel"), LinkButton)
36 l.Attributes.Add("onclick", "return getconfirm();")
37 End If
38
39 End Sub
40
41 Sub sectList_DeleteCommand(ByVal s As Object, ByVal e As DataGridCommandEventArgs)
42
43 Dim ConnectionStr As String = ConfigurationManager.AppSettings("ConnStr")
44 Dim conn As SqlConnection
45 Dim cmd As SqlCommand
46 Dim Id As Integer
47
48 Id = CInt(e.Item.Cells(0).Text)
49 conn = New SqlConnection("server=fileserver; uid=xxx; pwd=xxx; database=NEW_CMS")
50 cmd = New SqlCommand("delete from SECTION_TBL where SECT_ID = @SECT_ID", conn)
51 cmd.CommandType = CommandType.StoredProcedure
52 cmd.Parameters.Add("@SECT_ID", SqlDbType.Int).Value = Id
53
54 cmd.Connection.Open()
55 cmd.ExecuteNonQuery()
56 cmd.Connection.Close()
57
58 DataBind()
59
60 End Sub
61
62
63
64 </script>
65
66 <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
67
68 <script language="javascript">
69
70 function getconfirm()
71 {
72 if (confirm("Do you want to delete record?")==true)
73 return true;
74 else
75 return false;
76 }
77
78 </script>
79
80 <table cellpadding="2" cellspacing="2" width="760">
81 <tr>
82 <td>Sections</td>
83 </tr>
84 <tr>
85 <td>
86
87 <asp:DataGrid OnDeleteCommand="sectList_DeleteCommand" ID="sectList" runat="server" DataKeyField="SECT_ID" AutoGenerateColumns="False">
88
89 <Columns>
90
91 <asp:BoundColumn DataField="SECT_ID" Visible="False" />
92
93 <asp:HyperLinkColumn HeaderText="SECTION NAME" DataTextField="SECT_NAME" DataNavigateUrlField="SECT_ID" DataNavigateUrlFormatString="manageSection.aspx?SECT_ID={0}" />
94
95 <asp:TemplateColumn>
96 <ItemTemplate>
97 <asp:LinkButton id="cmdDel" runat="server" Text="Delete" CommandName="Delete" CausesValidation="false" />
98 </ItemTemplate>
99 </asp:TemplateColumn>
100
101 </Columns>
102
103 </asp:DataGrid>
104
105 </td>
106 </tr>
107 <tr>
108 <td></td>
109 </tr>
110 </table>
111
112 </asp:Content> Thanks in advance.
 

View 2 Replies View Related

SQLDataSource WITHOUT Using A Datagrid

Mar 10, 2008

Hi,
 I'm trying to use VS2005 to create an ASP.NET 2.0 application.  As part of this application I need to be able to read value from a SQL2005 database.  I used the connection string builder to create the connection string, but am unable to run a simple SELECT statement.  In .NET 1.1, I was able to do this pretty easily, but am unable to even find the same namespaces in .NET 2.0.
 For example (VS2003):
           'Construct new SQL statement            sqlDBDAHulls.SelectCommand.CommandText = "SELECT COUNT('HullID') FROM Hulls"            iNoRows = sqlDBDAHulls.SelectCommand.ExecuteScalar
            ReDim arrHullClass(iNoRows - 1)            ReDim arrHullDesign(iNoRows - 1)
            ddlHull.Items.Clear()
            For iArrLoop = LBound(arrHullClass) To UBound(arrHullClass)                'Redefine SQL statement                sqlDBDAHulls.SelectCommand.CommandText = "SELECT Class FROM Hulls WHERE (HullId = " + Trim(Str((iArrLoop + 1))) + ")"                'Populate array                arrHullClass(iArrLoop) = sqlDBDAHulls.SelectCommand.ExecuteScalar                'Redefine SQL Statement                sqlDBDAHulls.SelectCommand.CommandText = "SELECT Design FROM Hulls WHERE (HullId = " + Trim(Str((iArrLoop + 1))) + ")"                'Populate array                arrHullDesign(iArrLoop) = sqlDBDAHulls.SelectCommand.ExecuteScalar                'Populate combobox                ddlHull.Items.Insert(iArrLoop, arrHullClass(iArrLoop) + ":" + arrHullDesign(iArrLoop))            Next iArrLoop
            'Close the database            sqlConnBC.Close()
This all works absolutely fine.
 
In VS2005 there does not appear to be the same data adapter and sql client controls and I am starting to pull my hair out.  this is what I have:
ASP:
<asp:SqlDataSource ID="connSQL" runat="server" CancelSelectOnNullParameter="False" ConnectionString="Data Source=STREETROD;Initial Catalog=DVD;Persist Security Info=True;User ID=sa;Password=xj600f" DataSourceMode="DataReader" ProviderName="System.Data.SqlClient" FilterExpression="ID" SortParameterName="ID"></asp:SqlDataSource>
VB:

'Connect to database and read values
connSQL.ConnectionString = sConnStr
connSQL.SelectCommandType = SqlDataSourceCommandType.Text
connSQL.SelectCommand = "SELECT COUNT('ID') FROM Users"
iCount = connSQL.Select()ReDim sDbUN(iCount - 1)
ReDim sDbPW(iCount - 1)For iLoop = LBound(sDbUN) To UBound(sDbUN)

connSQL.SelectCommand = "SELECT 'UN' FROM Users WHERE 'ID'='" & Str(iLoop + 1) & "'"
sDbUN(iLoop) = connSQL.Select()
connSQL.SelectCommand = "SELECT 'PW' FROM Users WHERE 'ID'='" & Str(iLoop + 1) & "'"
sDbPW(iLoop) = connSQL.Select()
Next
 and all this keeps telling me is that I have not specified any.arguements under System.Web.UI.DataSourceSelectArguments.  I have even tried entering System.Web.UI.DataSourceSelectArguments.Empty to no avail
Can someone please give me a code example that will help me understand this, or at least point me in the right direction?  Or is that I simply HAVE to use a datagrid?
Many thanks.
ProudFoots

View 3 Replies View Related

Calculations In A Datagrid?

Mar 21, 2008

Hello,
I ran into a little problem. My problem is: i need to substract 2 variabeles from 2 different tables in the database 



TitleTimes left todayTimes left


My first excercise!15


My second excercise!19


The fields times left are a calculation... the number of times that the admin entered minus a count in the table scores.
Has anyone an idea how i can solve this?
An example excercise would be great!
Thanks in advance

View 5 Replies View Related

Element In Datagrid?

Mar 22, 2005

please help me to take element in datagrid?

View 1 Replies View Related

SQL Rollup In Datagrid

Jul 13, 2005

Hi,I am attempting to achieve some form of report that needs to make use of sql rollup and display it as follows:Category     Subject Matter1     Subject Matter2     Subject Matter3     No of CasesClubs             Facilities             Sport Facilities          Swimming Pool       3                     SubTotal                                                                     3Events             SBR/AHM                NULL                      NULL                1                     SubTotal                                                                     1                     GrandTotal                                                                     4However, with my sql query, using roll up, it will look like the following which is not correct.Category     Subject Matter1     Subject Matter2     Subject Matter3     No of CasesClubs             Facilities             Sport Facilities          Swimming Pool          3Clubs             Facilities             Sport Facilities             NULL                      3Clubs             Facilities             NULL                         NULL                      3Clubs             Sub Total             NULL                         NULL                      3Events             SBR/AHM             NULL                         NULL                      1Events              SBR/AHM             NULL                         NULL                     1Events             SBR/AHM             NULL                         NULL                      1Events             Sub Total             NULL                         NULL                      1This is the query I am using:<code>select casewhen (grouping(Cat.Description)=1) then 'Grand Total'else Cat.Descriptionend as Category,casewhen (grouping(sub.description)=1) then 'Sub Total'else Sub.descriptionend as SM1,SubSub.Description as SM2, SM.Description as SM3, count(sub.description)from tb_feedbackcase FB left join tb_category Cat on FB.Category_ID = Cat.Category_ID left join tb_subcategory Sub on FB.SubCategory_ID = Sub.SubCategory_IDleft join tb_subsubcategory SubSub on FB.SubSubCategory_ID = SubSub.SubSubCategory_IDleft join tb_SubjectMatterLV3 SM on FB.SM3_ID = SM.SM3_IDwhere fb.commenttype_id in (select commenttypes_id from tb_comment_types where description = @feedback_type)and convert(char(10),feedback_datetime,102) >= convert(char(10),@date_from, 102)and convert(char(10), feedback_datetime, 102) <= convert(char(10),@date_to, 102)group by Cat.Description, Sub.Description, SubSub.Description, SM.Description with rollup</code>How can I change it to reflect more accurately? Please help. Thanks.

View 1 Replies View Related

ASP.NET DataGrid Problem

Feb 4, 2006

Hi,
As a relative newbie to SQL Server/ASP.NET I'm hoping someone here can help with my problem. I'm developing a timesheet application in ASP.NET C# using Visual Studio 2003 with a database built in MSDE. One of my forms needs to return a simple list of resources from my database. I have followed the guide on the MSDN libraries, but for some reason I continuously get the same error message.
What I've done so far is Create the database, tables, and populate with some sample data using using Server Explorer in Visual Studio. I have connected to the database (using integrated security) and I am trying to get the contents of the Resource table to appear on my form. I have then created a DataAdapter (tested the connection, set the SQL as a simple SELECT * from Resource, etc), which also generates an sqlConnection for me. To test this I have previewed the generated data, and it returns what I want, so I have chosen to generate a DataSet of this. I am then trying to get this data into a simple DataGrid. On the properties of the DataGrid I have changed the DataSource to point at my Dataset. As I understand it, I then have to add the following to my Page Load section of my code.
sqlConnection1.Open();this.sqlDataAdapter1.Fill(this.dsResource);DataGrid1.DataBind();sqlConnection1.Close();
The form builds fine, but when I browse to the particular form I get the following error for the sqlConnection1.Open(); line. If I remove this line the error simply moves to the line below.
Exception Details: System.Data.SqlClient.SqlException: Cannot open database requested in login 'SCMS'. Login fails. Login failed for user 'AL-NOTEPADASPNET'.
To me this is an error with my connection string. My database instance is actually 'AL-NOTEPADVSDOTNET'.  However the properties for sqlConnection1 are pointing to the correct datasource. I do not know why the application is looking for user 'AL-NOTEPADASPNET'. It does not exist, to my knowledge. Do I need to grant access to this user? If so, how would I do it? Bearing in mind I am using MSDE, and do not have Enterprise Manager.
Any help with this would be greatly appreciated, as I get the same error with my code for forms-based login...
Thanks in advance..

View 2 Replies View Related

Pagination Without Datagrid

Mar 13, 2006

I'm working on a website where we're using .Net web services to feed data to a Flash front-end. The site will have a comments section and we want to display 15 or so comments per page with 'back' and 'next' functionalitiy. We'd also like to show the number of pages of comments and highlight the page they're on. The standard stuff that datagrids do so well. How can this be accomplished without a datagrid? There's a good page that explains a number of ways to do this using classic ASP. Some of the solutions they implement I can most likely use with .Net.http://www.aspfaq.com/show.asp?id=2120But I wanted to ask the community. How to paginate without a recordset? Sql Server 2000 back-end, ASP.NET 1.xThanks.

View 3 Replies View Related

Loop Through A Datagrid

Jul 23, 2005

Hi,No I don't want to loop through my dataset ;) I want to loop through mydatagrid to retrieve the values in each cells, but I don't know how todo that ?Can someone help ?thx

View 1 Replies View Related

C# SQL ID Field Datagrid And DataSource

Sep 14, 2006

OK I am a newbie when it comes to lots of .Net so if you answer go slowwww. I have an auto incrementing ID field in a SQL database.This is all displayed to the user in a datagrid control. I add two or three new rows and AcceptChanges.At this point I my ID field displayed on the grid bound tot he SQL ID field is out of Sync. What the #@^%#$&* In fact it looks like the data grid placed in its own numbers by doing some sort of Maxvalue on the column. HELP!  Bob  

View 3 Replies View Related

How To Get The Value Of A SQL Query Before Binding It To DataGrid?

Dec 4, 2006

I am using C#.Net, Visual web Developer, SQL server 2000. I have a SQL query which I am binding it to a DataGrid. SQL : "SELECT ord_number, ord_ID, ord_split, ord_Name, ETD_Date, OSP_FSD FROM ORDERS" In My DataGrid I have a dynamic databound column. I am able to bind one column to this databound column using following code. BoundColumn ETDDate = new BoundColumn(); ETDDate.HeaderText = "ETD Date"; ETDDate.DataField = "OSP_FSD"; mygrid2.Columns.AddAt(ETDDate); but now I want to bind this databound column based on the following criteria to two different database columns. if(ord_split = 1) { ETDDate.DataField = "OSP_FSD"; } else { ETDDate.DataField = "ETD_Date"; } How to get value of ord_split before binding SQL to teh DataGrid? i.e I just want to take value of ord_split and not all the values of SQL. Please Help!

View 1 Replies View Related

Error With Databound Datagrid

May 12, 2005

Help,
 I have a simple app that only has on datagrid that is bound by the typical sqlconnection,sqldataadapter and dataset.  But I keep getting this error:
Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.SqlClient.SqlException: Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection.Source Error:



Line 55: Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Line 56: 'Put user code to initialize the page here
Line 57: SqlDataAdapter1.Fill(DataSet11)
Line 58: DataGrid1.DataBind()
Line 59:
 
WHY :)

View 2 Replies View Related

Datagrid Dataset Problem

Jul 19, 2005

For a datagrid dataset,  I'm trying to take the amount of all the sales by a salesperson in two days and create an alias for sum(saleamount) (which would become allsales) to put the grand total in.
select     thedate, sum(saleamount) as allsales , salesperson, orderID from     transactions WHERE     (thedate IN ('6/1/2005', '6/2/2005')) GROUP BY Salesperson HAVING      SUM(allsales > 0)
I'm getting "invalid syntax near SUM (on the Having clause)" when trying to run this query. And I know there is data in there meeting this criteria.Thanks chumley

View 1 Replies View Related

Fully Editable Datagrid

Nov 10, 2005

I have been trying to formulate a fully editabe datagrid for a couple of days with no luck.  I have used code from 4guys and some other sites and am at the point where I can render the datagrid correctly (as a bouncolumn and template column-textbox) but when I try to update the database it all falls apart.  I am getting "input string was not in a correct format" and the error references ...Dim id as Integer = Convert.ToInt32(sls.DataKeys(dgi.ItemIndex))I suspect the problem lies in the area of primary indexes and such.  The table I am using is a simple two-column table with usernames, passwords.  Username is the primary field. Here is the actual code I am using...<code><%@ Page Explicit="True" Language="VB" Debug="True" %><%@ Import Namespace="System.Data" %><%@ Import Namespace="System.Data.OleDb" %><html>
<script runat="server">Dim Connect As OleDbConnection = New OleDbConnectionDim Adapter As OleDbDataAdapter = New OleDbDataAdapterDim DS As DataSet = New DataSetDim ConnectString, SelectStatement As String
Sub Page_Load(Sender As Object, E As EventArgs)
If Not IsPostBack Then SelectStatement = "Select * From Table"ConnectString = "Provider=SQLOLEDB;UID=;PWD=;" & "Data Source=;Initial Catalog=;"
Connect.ConnectionString = ConnectStringAdapter.SelectCommand = New oleDbCommand(SelectStatement, Connect)Adapter.SelectCommand.Connection.OpenAdapter.Fill(DS, "Items")sls.Datasource = DS.Tables("Items")Page.DatabindConnect.Close()End IfEnd Sub
Sub Click(sender As Object, e As EventArgs)  Dim myConnection as New OleDbConnection(ConnectString)Dim updateSQL as String = "UPDATE Table SET password = @Password WHERE Username = @ID"Dim myCommand as New oleDbCommand(updateSQL, myConnection)
Dim dgi as DataGridItemFor Each dgi in sls.Items  'Read in the Primary Key Field  Dim id as Integer = Convert.ToInt32(sls.DataKeys(dgi.ItemIndex))  Dim password as String = CType(dgi.FindControl("txtPass"), TextBox).Text
        'Issue an UPDATE statement...    myCommand.Parameters.Clear()  myCommand.Parameters.Add("@ID", id)  myCommand.Parameters.Add("@Password", password)
  myCommand.ExecuteNonQuery()Next
    End Sub
</script><body><form runat="Server">
<asp:datagrid id="sls" runat="server" AutoGenerateColumns="False" datakeyfield="Username">   <Columns>    <asp:BoundColumn HeaderText="UserName" datafield="Username"/>
         <asp:TemplateColumn HeaderText="Password">      <ItemTemplate>        <asp:TextBox runat="server" id="txtPass" Columns="10"              Text='<%# DataBinder.Eval(Container, "DataItem.Password") %>' />      </ItemTemplate>    </asp:TemplateColumn>
  </Columns> </asp:datagrid><asp:button id="Update" text="Update All" runat="Server" onclick="Click"/></form></body></html></code>Anyone have any idea as to why the id variable (error message above) is causing problems?

View 2 Replies View Related

Capturing Events In A DataGrid

Jul 20, 2005

I'm trying to add functionality to a VB 6 application allowingcustomer service to add a customer number to a new customer.Customers are added to the database by sales personnel, and aprospective customer may have multiple rows due to projected ordersfor multiple products. Customer numbers are assigned when a newcustomer makes their first order.I'm using a DataGrid connected to an ADO Data Control. The datacontrol is connected to a view in SQL Server using the 'distinct'directive (I know it's not updatable) to show only one line per newcustomer. What I wish to do is capture the update event (probablythrough the FieldChangeComplete routine of the data control), manuallyassign the newly entered customer number to all appropriate rows inthe database, and cancel the update event with no notifications.I'm having two problems:1. I can't capture the newly entered customer number. The Textproperty of the DataGrid returns the old value of the cell instead ofthe newly entered value. How do I get the edited value?2. Even though I set adStatus = adStatusCancel in theFieldChangeComplete routine, I get a Microsoft DataGrid Control dialogstating 'Operation was Canceled'. How do I avoid this notification?

View 1 Replies View Related

Must I Display A Column In DataGrid To Reference It?

Oct 11, 2006

Hi,I have a DataGrid whose DataSource is an SQLDataSource. This SQLDataSource references a SQL Server table with an Identity column, named Id. The SQLDataSource has generated an Update statement for me, but this only works if the Id column is selected for display in the DataGrid, and has Visible = True. If not, then the @original_Id parameter to the generated Update statement has a value of Nothing, and the Update has no effect. So is there a way to enable the Update statement to work, without the user having to see the Id column in the DataGrid? Many thanks,Keith.

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved