Click here to Skip to main content
15,910,661 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: Anyone using IIS7 successfully ? Pin
User 17164926-Dec-06 13:52
professionalUser 17164926-Dec-06 13:52 
GeneralRe: Anyone using IIS7 successfully ? Pin
Christian Graus6-Dec-06 14:04
protectorChristian Graus6-Dec-06 14:04 
AnswerRe: Anyone using IIS7 successfully ? Pin
Rama Krishna Vavilala6-Dec-06 14:06
Rama Krishna Vavilala6-Dec-06 14:06 
GeneralRe: Anyone using IIS7 successfully ? Pin
Christian Graus6-Dec-06 14:12
protectorChristian Graus6-Dec-06 14:12 
GeneralRe: Anyone using IIS7 successfully ? Pin
Rama Krishna Vavilala6-Dec-06 14:23
Rama Krishna Vavilala6-Dec-06 14:23 
GeneralRe: Anyone using IIS7 successfully ? Pin
Christian Graus6-Dec-06 19:18
protectorChristian Graus6-Dec-06 19:18 
QuestionExport to Excel. Pin
deepaks36-Dec-06 8:21
deepaks36-Dec-06 8:21 
Questionproblem updating datagrid values Pin
jonjoe906-Dec-06 6:25
jonjoe906-Dec-06 6:25 
im having a problem writing values back to the database. im using sql 2000. the values are pulled in from a datagrid the user can make multiple edits and get click a button that preforms a batch update.

below is the code for the button

Protected

Sub btnSave_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSave.Click

Dim txtPrelimDecisionCode, txtPrelimLetterIssued, txtFinalDecisionCode, txtFinalLetterIssued As TextBox

Dim studentId, classId As Label

Dim gvRow As GridViewRow

Dim sqlConn As New SqlConnection

Dim sqlComm As New SqlCommand

Dim sqlDr As SqlDataReader
sqlConn.ConnectionString = (

"data source=.; integrated security= true; initial catalog=dbStudentRecords;")



Try
sqlConn.Open()

sqlComm.Connection = sqlConn

sqlComm.CommandText =

"SELECT * FROM tblStudentDecision"
sqlDr = sqlComm.ExecuteReader


For Each gvRow In Me.dgResults.Rows

' obtain the values from the dataGrid
studentId =

CType(gvRow.Cells(0).FindControl("studentId"), Label)
classId =

CType(gvRow.Cells(1).FindControl("classId"), Label)
txtPrelimDecisionCode =

CType(gvRow.Cells(21).FindControl("txtprelimDecisionCode"), TextBox)
txtPrelimLetterIssued =

CType(gvRow.Cells(21).FindControl("txtPrelimLetterIssued"), TextBox)
txtFinalDecisionCode =

CType(gvRow.Cells(21).FindControl("txtFinalDecisionCode"), TextBox)
txtFinalLetterIssued =

CType(gvRow.Cells(21).FindControl("txtFinalLetterIssued"), TextBox)

'convert the dataGrid Values into the correct data types(not sure if i need this)

'Dim classIdValue As Integer = Convert.ToInt32(classId)

'Dim prelimDecisionCodeValue As Integer = Convert.ToInt32(txtPrelimDecisionCode)

'Dim prelimLetterIssuedValue As Boolean = Convert.ToBoolean(txtPrelimLetterIssued)

'Dim finalDecisionCodeValue As Integer = Convert.ToInt32(txtFinalDecisionCode)

'Dim finalLetterIssuedValue As Boolean = Convert.ToBoolean(txtFinalLetterIssued)

'values from dataGrid
'these values below are printing to the debug just fine

Debug.Print(studentId.Text)

Debug.Print(classId.Text)

Debug.Print(txtPrelimDecisionCode.Text)

Debug.Print(txtPrelimLetterIssued.Text)

Debug.Print(txtFinalDecisionCode.Text)

Debug.Print(txtFinalLetterIssued.Text)

sqlDr.Read()


If IsDBNull("StudentId") Then

'studentId = CType(gvRow.Cells(0).FindControl("studentId"), Label)
' if record does not exsist insert all fields- not sure of the syntax


'sqlComm.CommandText = "INSERT NEW RECORD"

'sqlComm.ExecuteNonQuery()



Else
' i want to update txtPrelimDecisionCode txtPrelimLetterIssued txtFinalDecisionCode txtFinalLetterIssued if the record already exsists

' i tried to get it working with the first value txtPrelimDecisionCode and then i was going to proceed with the rest but damm it dosent work!!

sqlComm.CommandText =

"UPDATE tblStudentDecision SET prelimDecisionCode='" & txtPrelimDecisionCode.Text & "' WHERE studentId='" & studentId.Text & "'"
sqlComm.ExecuteNonQuery()






End If

Next



Catch ex As SqlException
Trace.Warn(

"dbError: " & ex.Message)

Catch ex As Exception
Trace.Warn(

"Other error: " & ex.Message)

Finally




sqlConn.Close()




End Try



End Sub
i thought this would be straight forward but i seem to be having problems any help would be great!






steve
AnswerRe: problem updating datagrid values Pin
Vasudevan Deepak Kumar6-Dec-06 6:51
Vasudevan Deepak Kumar6-Dec-06 6:51 
AnswerRe: problem updating datagrid values Pin
ToddHileHoffer6-Dec-06 7:25
ToddHileHoffer6-Dec-06 7:25 
Questionhow to find out the row in ASp.net Pin
Rmesh6-Dec-06 5:27
Rmesh6-Dec-06 5:27 
AnswerRe: how to find out the row in ASp.net Pin
l0kke6-Dec-06 6:45
l0kke6-Dec-06 6:45 
AnswerRe: how to find out the row in ASp.net Pin
Vasudevan Deepak Kumar6-Dec-06 6:48
Vasudevan Deepak Kumar6-Dec-06 6:48 
Questionhow to write write code in asp.net? Pin
Rmesh6-Dec-06 5:17
Rmesh6-Dec-06 5:17 
AnswerRe: how to write write code in asp.net? Pin
l0kke6-Dec-06 6:43
l0kke6-Dec-06 6:43 
AnswerRe: how to write write code in asp.net? Pin
Vasudevan Deepak Kumar6-Dec-06 6:47
Vasudevan Deepak Kumar6-Dec-06 6:47 
AnswerRe: how to write write code in asp.net? Pin
Smiles746-Dec-06 9:36
Smiles746-Dec-06 9:36 
GeneralRe: how to write write code in asp.net? Pin
szukuro7-Dec-06 1:55
szukuro7-Dec-06 1:55 
Question' ' and NVL(abc,'') [modified] Pin
Smiles746-Dec-06 5:17
Smiles746-Dec-06 5:17 
Questionhow can i find and html element position Pin
m.rastgar6-Dec-06 3:20
m.rastgar6-Dec-06 3:20 
QuestionMousehover control in code behind Pin
krishna_mag6-Dec-06 3:16
krishna_mag6-Dec-06 3:16 
AnswerRe: Mousehover control in code behind Pin
eggsovereasy6-Dec-06 3:38
eggsovereasy6-Dec-06 3:38 
Questionupload file security risk? Pin
abdz6-Dec-06 2:47
abdz6-Dec-06 2:47 
AnswerRe: upload file security risk? Pin
Vasudevan Deepak Kumar6-Dec-06 6:50
Vasudevan Deepak Kumar6-Dec-06 6:50 
AnswerRe: upload file security risk? Pin
l0kke6-Dec-06 6:52
l0kke6-Dec-06 6:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.