Click here to Skip to main content
16,004,991 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: 'Generate Managed Class' Pin
Dave Kreskowiak27-Jan-06 18:26
mveDave Kreskowiak27-Jan-06 18:26 
AnswerRe: 'Generate Managed Class' Pin
Mekong River28-Jan-06 5:47
Mekong River28-Jan-06 5:47 
GeneralRe: 'Generate Managed Class' Pin
Dave Kreskowiak28-Jan-06 10:21
mveDave Kreskowiak28-Jan-06 10:21 
QuestionCrystal Reports Pin
shakizil27-Jan-06 4:24
shakizil27-Jan-06 4:24 
QuestionDatabase Question Pin
Derek G27-Jan-06 3:53
Derek G27-Jan-06 3:53 
AnswerRe: Database Question Pin
Dave Kreskowiak27-Jan-06 4:37
mveDave Kreskowiak27-Jan-06 4:37 
GeneralRe: Database Question Pin
Derek G27-Jan-06 4:50
Derek G27-Jan-06 4:50 
QuestionThe ConnectionString property has not been initialized Pin
ashrita27-Jan-06 3:38
ashrita27-Jan-06 3:38 
Hi, I'm new to VB.NET. I use a datalist to display and edit my records form Access database.

I got problems whenever I try to update or delete a record, it gives me "The ConnectionString property has not been initialized" error. Does anybody has any idea how to solve this problem? Where should I change the code? Please show me how to do it. Thanks.

Here's the code:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If Not IsPostBack Then
LoadData()
End If
End Sub

Public Sub LoadData()
strconn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("CampusVoting.mdb")

myconnection = New OleDbConnection(strconn)
cmdReq.CommandText = "select * from News"

cmdReq.Connection = myconnection
cmdReq.Connection.Open()

dr = cmdReq.ExecuteReader
NewsList.DataSource = dr
NewsList.DataBind()
cmdReq.Connection.Close()
End Sub

Sub Del_Command(ByVal sender As Object, ByVal e As DataListCommandEventArgs)

Dim title As String
title = NewsList.DataKeys(e.Item.ItemIndex)
Dim cm As New OleDbCommand("delete from News where NewsID = " & title & "", myconnection)
cm.Connection.Open()
cm.ExecuteNonQuery()
cm.Connection.Close()
LoadData()
End Sub
Sub Cancel_Command(ByVal sender As Object, _
ByVal e As DataListCommandEventArgs)
NewsList.EditItemIndex = -1
LoadData()
End Sub

Sub Edit_Command(ByVal sender As Object, _
ByVal e As DataListCommandEventArgs)
NewsList.EditItemIndex = e.Item.ItemIndex
LoadData()
End Sub
Sub Update_Command(ByVal sender As Object, _
ByVal e As DataListCommandEventArgs)
Dim tbox As TextBox
Dim Title_id As String
Dim Title, Descr As TextBox

title_id = NewsList.DataKeys(e.Item.ItemIndex)

Title = e.Item.FindControl("NewsTitle")
Descr = e.Item.FindControl("NewsDesr")

Dim cmd As New OleDbCommand("Update News set NewsTitle = '" & Title.Text & "', NewsDesr='" & Descr.Text & "' where NewsID=" & Title_id & "", myconnection)

cmd.Connection.Open()
cmd.ExecuteNonQuery()
cmd.Connection.Close()

NewsList.EditItemIndex = -1
LoadData()
End Sub

AnswerRe: The ConnectionString property has not been initialized Pin
Dave Kreskowiak27-Jan-06 4:33
mveDave Kreskowiak27-Jan-06 4:33 
GeneralRe: The ConnectionString property has not been initialized Pin
ashrita27-Jan-06 17:30
ashrita27-Jan-06 17:30 
QuestionDisable or hide a tab page Pin
directred27-Jan-06 3:35
directred27-Jan-06 3:35 
AnswerRe: Disable or hide a tab page Pin
Dave Kreskowiak27-Jan-06 4:21
mveDave Kreskowiak27-Jan-06 4:21 
GeneralRe: Disable or hide a tab page Pin
Mekong River27-Jan-06 4:27
Mekong River27-Jan-06 4:27 
GeneralRe: Disable or hide a tab page Pin
Dave Kreskowiak27-Jan-06 6:00
mveDave Kreskowiak27-Jan-06 6:00 
GeneralRe: Disable or hide a tab page Pin
Mekong River28-Jan-06 2:20
Mekong River28-Jan-06 2:20 
GeneralRe: Disable or hide a tab page Pin
Dave Kreskowiak28-Jan-06 10:16
mveDave Kreskowiak28-Jan-06 10:16 
GeneralRe: Disable or hide a tab page Pin
Mekong River28-Jan-06 12:53
Mekong River28-Jan-06 12:53 
GeneralRe: Disable or hide a tab page Pin
directred27-Jan-06 4:28
directred27-Jan-06 4:28 
GeneralRe: Disable or hide a tab page Pin
directred27-Jan-06 4:42
directred27-Jan-06 4:42 
GeneralRe: Disable or hide a tab page Pin
[Marc]27-Jan-06 5:29
[Marc]27-Jan-06 5:29 
GeneralRe: Disable or hide a tab page Pin
Dave Kreskowiak27-Jan-06 5:55
mveDave Kreskowiak27-Jan-06 5:55 
Questiontransparent label Pin
rzvme27-Jan-06 3:19
rzvme27-Jan-06 3:19 
AnswerRe: transparent label Pin
Dave Kreskowiak27-Jan-06 4:15
mveDave Kreskowiak27-Jan-06 4:15 
AnswerRe: transparent label Pin
JUNEYT27-Jan-06 7:29
JUNEYT27-Jan-06 7:29 
GeneralRe: transparent label Pin
rzvme27-Jan-06 7:46
rzvme27-Jan-06 7:46 

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.