VB Problem

Asked By Chempaka Sari
06-Sep-10 01:48 AM
Earn up to 0 extra points for answering this tough question.
hye there...

this code did not give me any output. please help me

Imports system.data
Imports system.data.oledb
Imports System.data.SqlClient
Imports System.data.SqlClient.SqlDataReader
 
 
Partial Class testALert
  Inherits System.Web.UI.Page
  Dim con As New OleDb.OleDbConnection
  Dim dbProvider As String
  Dim dbSource As String
  Dim detReport As OleDbCommand
  Dim drRef As OleDbDataReader
  Dim dg As DataGrid
  Dim resultDSO As Double
 
  Private Sub Detailreport_Click()
 
    dbProvider = "PROVIDER=Microsoft.Jet.OLEDB.4.0;"
    dbSource = "Data Source = C:\Users\MC-dy\Desktop\CSGFunctionalitiesMadiNyerPart\DoItTryIt\CSG1.2.mdb"
 
    con.ConnectionString = dbProvider & dbSource
 
    Try
 
      con.Open()
 
      detReport = New OleDbCommand("select r.StockLongName, r.StockCode, r.Board, r.Sector, r.SubSector, r.FYE, q.MarketCapLocal FROM referential r inner join quarter q on r.stockcode = q.stockcode", con)
 
      'Select Referential.StockCode, Referential.StockLongName,Quarter.TotalCurrentAsset, Quarter.CurrentLiabilities, Format(Quarter.TotalCurrentAssets / Quarter.CurrentLiabilities, "\0.00"\)AS CurrentRatio From Referential INNER JOIN Quarter ON Referential.StockCode = Quarter.StockCode WHERE(Quarter.CurrentLiabilities <> \""\;\
      drRef = detReport.ExecuteReader()
 
      GridView1.DataSource = drRef
      GridView1.DataBind()
 
      con.Close()
 
    Catch ex As Exception
      MsgBox("cannot open connection")
    End Try
 
 
  End Sub
 
End Class

  re: VB Problem

Anand Malli replied to Chempaka Sari
06-Sep-10 01:56 AM
Hi Sambal,

your code looks ok to me,what i will advice you to check is in your db it may happen that there no entry for the stock for particular quarter with for stockcode,so what happens is no rows are coming in output and so your grid is not getting bind

can you just check that??? or just try binding your grid first with only single query to check your code is working

ping me with update
THXS

  re: VB Problem

Web Star replied to Chempaka Sari
06-Sep-10 02:04 AM

code looks like ok only you need to check your query and make sure that query retrun values means the value should be exists in table on that condition

you also see this is working code

private void ReadRecords()
{
  OleDbConnection conn = null;
  OleDbDataReader reader = null;
  try
  {
    conn = new OleDbConnection(
      "Provider=Microsoft.Jet.OLEDB.4.0; " +
      "Data Source=" + Server.MapPath("Pets/Pets.mdb"));
    conn.Open();

    OleDbCommand cmd =
      new OleDbCommand("Select * FROM PetTable", conn);
    reader = cmd.ExecuteReader();

    datagrid.DataSource = reader;
    datagrid.DataBind();
}
//    catch (Exception e)
//    {
//      Response.Write(e.Message);
//      Response.End();
//    }
  finally
  {
    if (reader != null)  reader.Close();
    if (conn != null)  conn.Close();
  }
}

  re: VB Problem

Chempaka Sari replied to Web Star
06-Sep-10 02:40 AM
okeyh...thnk you so much to all..im still work on it!
Create New Account